summary refs log tree commit diff
path: root/src/voip/CallManager.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-19 01:38:40 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-19 01:38:40 +0200
commitce1a64bc19ffc21e115bdf2587bb053d7a417f3e (patch)
treea195d127228218772a535448de642f0bb7b6d053 /src/voip/CallManager.cpp
parentRemove explicit link styling (diff)
downloadnheko-ce1a64bc19ffc21e115bdf2587bb053d7a417f3e.tar.xz
Move to automatic type registration
Diffstat (limited to 'src/voip/CallManager.cpp')
-rw-r--r--src/voip/CallManager.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp

index feb06835..5479ba31 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp
@@ -54,6 +54,27 @@ std::vector<std::string> getTurnURIs(const mtx::responses::TurnServer &turnServer); } +CallManager * +CallManager::create(QQmlEngine *qmlEngine, QJSEngine *) +{ + // The instance has to exist before it is used. We cannot replace it. + auto instance = ChatPage::instance()->callManager(); + Q_ASSERT(instance); + + // The engine has to have the same thread affinity as the singleton. + Q_ASSERT(qmlEngine->thread() == instance->thread()); + + // There can only be one engine accessing the singleton. + static QJSEngine *s_engine = nullptr; + if (s_engine) + Q_ASSERT(qmlEngine == s_engine); + else + s_engine = qmlEngine; + + QJSEngine::setObjectOwnership(instance, QJSEngine::CppOwnership); + return instance; +} + CallManager::CallManager(QObject *parent) : QObject(parent) , session_(WebRTCSession::instance())