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 () {
mCoreStartedLock->unlock();
}
void CoreHandlers::handleCoreStarted () {
mCoreStartedLock->lock();
Q_ASSERT(mCoreStarted == false);
mCoreStarted = true;
notifyCoreStarted();
mCoreStartedLock->unlock();
}
void CoreHandlers::notifyCoreStarted () {
if (mCoreCreated && mCoreStarted)
scheduleFunctionInApp(
......@@ -128,8 +118,15 @@ void CoreHandlers::onGlobalStateChanged (
linphone::GlobalState gstate,
const string &
) {
if (gstate == linphone::GlobalStateOn)
handleCoreStarted();
if (gstate == linphone::GlobalStateOn) {
mCoreStartedLock->lock();
Q_ASSERT(mCoreStarted == false);
mCoreStarted = true;
notifyCoreStarted();
mCoreStartedLock->unlock();
}
}
void CoreHandlers::onCallStatsUpdated (
......
......@@ -52,7 +52,6 @@ signals:
private:
void handleCoreCreated ();
void handleCoreStarted ();
void notifyCoreStarted ();
// ---------------------------------------------------------------------------
......
......@@ -46,18 +46,22 @@ CoreManager *CoreManager::mInstance = nullptr;
CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath);
QObject::connect(&mPromiseWatcher, &QFutureWatcher<void>::finished, this, []() {
mInstance->mCallsListModel = new CallsListModel(mInstance);
mInstance->mContactsListModel = new ContactsListModel(mInstance);
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
mInstance->mSettingsModel = new SettingsModel(mInstance);
mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
qInfo() << QStringLiteral("Core created. Enable iterate.");
mInstance->mCbsTimer->start();
emit mInstance->coreCreated();
});
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->mContactsListModel = new ContactsListModel(mInstance);
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
mInstance->mSettingsModel = new SettingsModel(mInstance);
mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
emit mInstance->coreStarted();
});
mPromiseWatcher.setFuture(mPromiseBuild);
}
......
......@@ -121,6 +121,7 @@ public:
signals:
void coreCreated ();
void coreStarted ();
private:
CoreManager (QObject *parent, const QString &configPath);
......
linphone @ e3365011
Subproject commit 4c291e2c5a32711a1176459d74ed405cf225f706
Subproject commit e3365011df5d5281fed91beb91fa928ac3568f60
......@@ -51,7 +51,7 @@ ApplicationWindow {
Connections {
target: CoreManager
onCoreCreated: mainLoader.active = true
onCoreStarted: mainLoader.active = true
}
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