Commit 1a2e5e5e authored by Ronan Abhamon's avatar Ronan Abhamon

fix(CoreManager): create main components at core startup

parent 5695e8ac
...@@ -72,16 +72,6 @@ void CoreHandlers::handleCoreCreated () { ...@@ -72,16 +72,6 @@ void CoreHandlers::handleCoreCreated () {
mCoreStartedLock->unlock(); mCoreStartedLock->unlock();
} }
void CoreHandlers::handleCoreStarted () {
mCoreStartedLock->lock();
Q_ASSERT(mCoreStarted == false);
mCoreStarted = true;
notifyCoreStarted();
mCoreStartedLock->unlock();
}
void CoreHandlers::notifyCoreStarted () { void CoreHandlers::notifyCoreStarted () {
if (mCoreCreated && mCoreStarted) if (mCoreCreated && mCoreStarted)
scheduleFunctionInApp( scheduleFunctionInApp(
...@@ -128,8 +118,15 @@ void CoreHandlers::onGlobalStateChanged ( ...@@ -128,8 +118,15 @@ void CoreHandlers::onGlobalStateChanged (
linphone::GlobalState gstate, linphone::GlobalState gstate,
const string & const string &
) { ) {
if (gstate == linphone::GlobalStateOn) if (gstate == linphone::GlobalStateOn) {
handleCoreStarted(); mCoreStartedLock->lock();
Q_ASSERT(mCoreStarted == false);
mCoreStarted = true;
notifyCoreStarted();
mCoreStartedLock->unlock();
}
} }
void CoreHandlers::onCallStatsUpdated ( void CoreHandlers::onCallStatsUpdated (
......
...@@ -52,7 +52,6 @@ signals: ...@@ -52,7 +52,6 @@ signals:
private: private:
void handleCoreCreated (); void handleCoreCreated ();
void handleCoreStarted ();
void notifyCoreStarted (); void notifyCoreStarted ();
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -46,17 +46,21 @@ CoreManager *CoreManager::mInstance = nullptr; ...@@ -46,17 +46,21 @@ CoreManager *CoreManager::mInstance = nullptr;
CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) { CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath); mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath);
QObject::connect(&mPromiseWatcher, &QFutureWatcher<void>::finished, this, []() { QObject::connect(&mPromiseWatcher, &QFutureWatcher<void>::finished, this, [] {
qInfo() << QStringLiteral("Core created. Enable iterate.");
mInstance->mCbsTimer->start();
emit mInstance->coreCreated();
});
QObject::connect(mHandlers.get(), &CoreHandlers::coreStarted, this, [] {
mInstance->mCallsListModel = new CallsListModel(mInstance); mInstance->mCallsListModel = new CallsListModel(mInstance);
mInstance->mContactsListModel = new ContactsListModel(mInstance); mInstance->mContactsListModel = new ContactsListModel(mInstance);
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance); mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
mInstance->mSettingsModel = new SettingsModel(mInstance); mInstance->mSettingsModel = new SettingsModel(mInstance);
mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance); mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
qInfo() << QStringLiteral("Core created. Enable iterate."); emit mInstance->coreStarted();
mInstance->mCbsTimer->start();
emit mInstance->coreCreated();
}); });
mPromiseWatcher.setFuture(mPromiseBuild); mPromiseWatcher.setFuture(mPromiseBuild);
......
...@@ -121,6 +121,7 @@ public: ...@@ -121,6 +121,7 @@ public:
signals: signals:
void coreCreated (); void coreCreated ();
void coreStarted ();
private: private:
CoreManager (QObject *parent, const QString &configPath); CoreManager (QObject *parent, const QString &configPath);
......
linphone @ e3365011
Subproject commit 4c291e2c5a32711a1176459d74ed405cf225f706 Subproject commit e3365011df5d5281fed91beb91fa928ac3568f60
...@@ -51,7 +51,7 @@ ApplicationWindow { ...@@ -51,7 +51,7 @@ ApplicationWindow {
Connections { Connections {
target: CoreManager target: CoreManager
onCoreCreated: mainLoader.active = true onCoreStarted: mainLoader.active = true
} }
Shortcut { Shortcut {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment