Fix restart with core/models reallocations.
This commit is contained in:
parent
56dc3db046
commit
723731c7e5
5 changed files with 34 additions and 25 deletions
|
|
@ -444,7 +444,7 @@ void App::initCore() {
|
||||||
if (mParser->isSet("qt-logs-only")) QtLogger::enableQtOnly(true);
|
if (mParser->isSet("qt-logs-only")) QtLogger::enableQtOnly(true);
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
mLinphoneThread->getThreadId(),
|
mLinphoneThread->getThreadId(),
|
||||||
[this]() mutable {
|
[this, settings = mSettings]() mutable {
|
||||||
lInfo() << log().arg("Updating downloaded codec files");
|
lInfo() << log().arg("Updating downloaded codec files");
|
||||||
ToolModel::updateCodecs(); // removing codec updates suffic (.in) before the core is created.
|
ToolModel::updateCodecs(); // removing codec updates suffic (.in) before the core is created.
|
||||||
lInfo() << log().arg("Starting Core");
|
lInfo() << log().arg("Starting Core");
|
||||||
|
|
@ -454,7 +454,7 @@ void App::initCore() {
|
||||||
lDebug() << log().arg("Creating SettingsModel");
|
lDebug() << log().arg("Creating SettingsModel");
|
||||||
SettingsModel::create();
|
SettingsModel::create();
|
||||||
lDebug() << log().arg("Creating SettingsCore");
|
lDebug() << log().arg("Creating SettingsCore");
|
||||||
auto settings = SettingsCore::create();
|
if (!settings) settings = SettingsCore::create();
|
||||||
lDebug() << log().arg("Creating Ui");
|
lDebug() << log().arg("Creating Ui");
|
||||||
QMetaObject::invokeMethod(App::getInstance()->thread(), [this, settings, coreStarted] {
|
QMetaObject::invokeMethod(App::getInstance()->thread(), [this, settings, coreStarted] {
|
||||||
// QML
|
// QML
|
||||||
|
|
@ -501,24 +501,22 @@ void App::initCore() {
|
||||||
|
|
||||||
// Enable notifications.
|
// Enable notifications.
|
||||||
mNotifier = new Notifier(mEngine);
|
mNotifier = new Notifier(mEngine);
|
||||||
mSettings = settings;
|
mEngine->setObjectOwnership(settings.get(), QQmlEngine::CppOwnership);
|
||||||
mEngine->setObjectOwnership(mSettings.get(), QQmlEngine::CppOwnership);
|
|
||||||
mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||||
setAccountList(AccountList::create());
|
if (!mAccountList) setAccountList(AccountList::create());
|
||||||
setCallList(CallList::create());
|
else mAccountList->lUpdate();
|
||||||
setAutoStart(mSettings->getAutoStart());
|
if (!mCallList) setCallList(CallList::create());
|
||||||
setQuitOnLastWindowClosed(mSettings->getExitOnClose());
|
else mCallList->lUpdate();
|
||||||
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
|
||||||
Qt::UniqueConnection);
|
|
||||||
setLocale(settings->getConfigLocale());
|
|
||||||
|
|
||||||
if (mSettings) {
|
if (!mSettings) {
|
||||||
|
mSettings = settings;
|
||||||
|
setLocale(settings->getConfigLocale());
|
||||||
|
setAutoStart(settings->getAutoStart());
|
||||||
|
setQuitOnLastWindowClosed(settings->getExitOnClose());
|
||||||
mEngine->setObjectOwnership(mSettings.get(), QQmlEngine::CppOwnership);
|
mEngine->setObjectOwnership(mSettings.get(), QQmlEngine::CppOwnership);
|
||||||
setAutoStart(mSettings->getAutoStart());
|
|
||||||
setQuitOnLastWindowClosed(mSettings->getExitOnClose());
|
|
||||||
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
setLocale(mSettings->getConfigLocale());
|
|
||||||
QObject::connect(mSettings.get(), &SettingsCore::autoStartChanged, [this]() {
|
QObject::connect(mSettings.get(), &SettingsCore::autoStartChanged, [this]() {
|
||||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
setAutoStart(mSettings->getAutoStart());
|
setAutoStart(mSettings->getAutoStart());
|
||||||
|
|
@ -527,6 +525,12 @@ void App::initCore() {
|
||||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
if (mSettings) setLocale(mSettings->getConfigLocale());
|
if (mSettings) setLocale(mSettings->getConfigLocale());
|
||||||
});
|
});
|
||||||
|
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
||||||
|
Qt::UniqueConnection);
|
||||||
|
} else {
|
||||||
|
setLocale(settings->getConfigLocale());
|
||||||
|
setAutoStart(settings->getAutoStart());
|
||||||
|
setQuitOnLastWindowClosed(settings->getExitOnClose());
|
||||||
}
|
}
|
||||||
const QUrl url("qrc:/qt/qml/Linphone/view/Page/Window/Main/MainWindow.qml");
|
const QUrl url("qrc:/qt/qml/Linphone/view/Page/Window/Main/MainWindow.qml");
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
|
@ -683,14 +687,14 @@ void App::restart() {
|
||||||
mEngine->clearSingletons();
|
mEngine->clearSingletons();
|
||||||
delete mEngine;
|
delete mEngine;
|
||||||
mEngine = nullptr;
|
mEngine = nullptr;
|
||||||
if (mSettings) mSettings.reset();
|
// if (mSettings) mSettings.reset();
|
||||||
initCore();
|
initCore();
|
||||||
// Retrieve self from current Core/Model connection and reset Qt connections.
|
// Retrieve self from current Core/Model connection and reset Qt connections.
|
||||||
auto oldConnection = mCoreModelConnection;
|
// auto oldConnection = mCoreModelConnection;
|
||||||
oldConnection->mCore.lock();
|
// oldConnection->mCore.lock();
|
||||||
auto me = oldConnection->mCore.mQData;
|
// auto me = oldConnection->mCore.mQData;
|
||||||
setSelf(me);
|
// setSelf(me);
|
||||||
oldConnection->mCore.unlock();
|
// oldConnection->mCore.unlock();
|
||||||
exit((int)StatusCode::gRestartCode);
|
exit((int)StatusCode::gRestartCode);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ CoreModel::~CoreModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CoreModel> CoreModel::create(const QString &configPath, QThread *parent) {
|
std::shared_ptr<CoreModel> CoreModel::create(const QString &configPath, QThread *parent) {
|
||||||
|
if (gCoreModel) return gCoreModel;
|
||||||
auto model = std::make_shared<CoreModel>(configPath, parent);
|
auto model = std::make_shared<CoreModel>(configPath, parent);
|
||||||
model->setSelf(model);
|
model->setSelf(model);
|
||||||
gCoreModel = model;
|
gCoreModel = model;
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ SettingsModel::~SettingsModel() {
|
||||||
|
|
||||||
shared_ptr<SettingsModel> SettingsModel::create() {
|
shared_ptr<SettingsModel> SettingsModel::create() {
|
||||||
// auto model = Utils::makeQObject_ptr<SettingsModel>();
|
// auto model = Utils::makeQObject_ptr<SettingsModel>();
|
||||||
|
if (gSettingsModel) return gSettingsModel;
|
||||||
auto model = make_shared<SettingsModel>();
|
auto model = make_shared<SettingsModel>();
|
||||||
gSettingsModel = model;
|
gSettingsModel = model;
|
||||||
return model;
|
return model;
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,12 @@ ApplicationWindow {
|
||||||
onPopupCountChanged: {
|
onPopupCountChanged: {
|
||||||
nextY = mainWindow.height
|
nextY = mainWindow.height
|
||||||
for(var i = 0; i < popupCount; ++i) {
|
for(var i = 0; i < popupCount; ++i) {
|
||||||
popupList[i].y = nextY - popupList[i].height
|
var popupItem = popupList[i]
|
||||||
popupList[i].index = i
|
if( popupItem ){
|
||||||
nextY = nextY - popupList[i].height - 15
|
popupItem.y = nextY - popupItem.height
|
||||||
|
popupItem.index = i
|
||||||
|
nextY = nextY - popupItem.height - 15
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ AbstractWindow {
|
||||||
Component {
|
Component {
|
||||||
id: loginPage
|
id: loginPage
|
||||||
LoginPage {
|
LoginPage {
|
||||||
showBackButton: accountProxy.haveAccount
|
showBackButton: accountProxy?.haveAccount || false
|
||||||
onGoBack: openMainPage()
|
onGoBack: openMainPage()
|
||||||
onUseSIPButtonClicked: mainWindowStackView.push(sipLoginPage)
|
onUseSIPButtonClicked: mainWindowStackView.push(sipLoginPage)
|
||||||
onGoToRegister: mainWindowStackView.replace(registerPage)
|
onGoToRegister: mainWindowStackView.replace(registerPage)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue