fix(CoreManager): create main components at core startup

This commit is contained in:
Ronan Abhamon 2017-06-15 11:52:21 +02:00
parent 5695e8ac6d
commit 1a2e5e5e8a
6 changed files with 26 additions and 25 deletions

View file

@ -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 (

View file

@ -52,7 +52,6 @@ signals:
private:
void handleCoreCreated ();
void handleCoreStarted ();
void notifyCoreStarted ();
// ---------------------------------------------------------------------------

View file

@ -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);
QObject::connect(&mPromiseWatcher, &QFutureWatcher<void>::finished, this, [] {
qInfo() << QStringLiteral("Core created. Enable iterate.");
mInstance->mCbsTimer->start();
qInfo() << QStringLiteral("Core created. Enable iterate.");
mInstance->mCbsTimer->start();
emit mInstance->coreCreated();
});
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);
}

View file

@ -121,6 +121,7 @@ public:
signals:
void coreCreated ();
void coreStarted ();
private:
CoreManager (QObject *parent, const QString &configPath);

@ -1 +1 @@
Subproject commit 4c291e2c5a32711a1176459d74ed405cf225f706
Subproject commit e3365011df5d5281fed91beb91fa928ac3568f60

View file

@ -51,7 +51,7 @@ ApplicationWindow {
Connections {
target: CoreManager
onCoreCreated: mainLoader.active = true
onCoreStarted: mainLoader.active = true
}
Shortcut {