From b53be20664e51372f254d1fbace23cbd1eb13e82 Mon Sep 17 00:00:00 2001 From: Skycoder42 Date: Sun, 17 Jun 2018 16:29:50 +0200 Subject: [PATCH] make all qml incubations synchronous Seems to be a bug with 5.11 where async loading leads to strange errors, i.e. a crash on an error report of a non existing property that actually exists... Check for validity in future versions! --- src/imports/mvvmquick/DialogPresenter.qml | 8 ++++---- src/imports/mvvmquick/InputDialog.qml | 2 +- src/imports/mvvmquick/SettingsView.qml | 9 ++++----- src/imports/mvvmquick/qqmlquickpresenter.cpp | 2 +- src/imports/mvvmquick/settingsuibuilder.cpp | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/imports/mvvmquick/DialogPresenter.qml b/src/imports/mvvmquick/DialogPresenter.qml index 3c7fa1e..7bf4fbc 100644 --- a/src/imports/mvvmquick/DialogPresenter.qml +++ b/src/imports/mvvmquick/DialogPresenter.qml @@ -184,7 +184,7 @@ QtObject { var props = config.viewProperties; props["msgConfig"] = config; props["msgResult"] = result; - var incubator = _msgBoxComponent.incubateObject(rootItem, props); + var incubator = _msgBoxComponent.incubateObject(rootItem, props, Qt.Synchronous); return incubator.status !== Component.Error; } @@ -204,7 +204,7 @@ QtObject { var props = config.viewProperties; props["msgConfig"] = config; props["msgResult"] = result; - var incubator = _inputComponent.incubateObject(rootItem, props); + var incubator = _inputComponent.incubateObject(rootItem, props, Qt.Synchronous); return incubator.status !== Component.Error; } @@ -226,9 +226,9 @@ QtObject { props["msgResult"] = result; var incubator = null; if(config.subType == "folder") - incubator = _folderComponent.incubateObject(rootItem, props); + incubator = _folderComponent.incubateObject(rootItem, props, Qt.Synchronous); else - incubator = _fileComponent.incubateObject(rootItem, props); + incubator = _fileComponent.incubateObject(rootItem, props, Qt.Synchronous); return incubator.status !== Component.Error; } } diff --git a/src/imports/mvvmquick/InputDialog.qml b/src/imports/mvvmquick/InputDialog.qml index d197781..0f65a3f 100644 --- a/src/imports/mvvmquick/InputDialog.qml +++ b/src/imports/mvvmquick/InputDialog.qml @@ -38,7 +38,7 @@ MsgBoxBase { Loader { id: _inputViewLoad - asynchronous: true + asynchronous: false clip: true visible: _inputViewLoad.item diff --git a/src/imports/mvvmquick/SettingsView.qml b/src/imports/mvvmquick/SettingsView.qml index 1a033e7..1b31b03 100644 --- a/src/imports/mvvmquick/SettingsView.qml +++ b/src/imports/mvvmquick/SettingsView.qml @@ -256,13 +256,12 @@ Page { filterText: _searchField.text onPresentOverview: _overviewComponent.incubateObject(_settingsStack, { - model: model, - showSections: hasSections - }, Qt.Asynchronous) + model: model, + showSections: hasSections + }, Qt.Synchronous) onPresentSection: _sectionViewComponent.incubateObject(_settingsStack, { model: model - }, Qt.Asynchronous) - + }, Qt.Synchronous) onCloseSettings: { _settingsView.fullClose = true; QuickPresenter.popView(); diff --git a/src/imports/mvvmquick/qqmlquickpresenter.cpp b/src/imports/mvvmquick/qqmlquickpresenter.cpp index cf574bc..e8301ae 100644 --- a/src/imports/mvvmquick/qqmlquickpresenter.cpp +++ b/src/imports/mvvmquick/qqmlquickpresenter.cpp @@ -123,7 +123,7 @@ void QQmlQuickPresenter::present(ViewModel *viewModel, const QVariantHash ¶m this, &QQmlQuickPresenter::loadingProgressChanged); connect(_latestComponent, &QQmlComponent::statusChanged, this, &QQmlQuickPresenter::statusChanged); - _latestComponent->loadUrl(viewUrl, QQmlComponent::Asynchronous); + _latestComponent->loadUrl(viewUrl, QQmlComponent::PreferSynchronous); } } diff --git a/src/imports/mvvmquick/settingsuibuilder.cpp b/src/imports/mvvmquick/settingsuibuilder.cpp index 262a420..bd812be 100644 --- a/src/imports/mvvmquick/settingsuibuilder.cpp +++ b/src/imports/mvvmquick/settingsuibuilder.cpp @@ -39,7 +39,7 @@ void SettingsUiBuilder::loadSection(const SettingsElements::Section §ion) { auto inputFactory = QuickPresenterPrivate::currentPresenter()->inputViewFactory(); _entryModel->setup(section, _viewModel, inputFactory); - qmlDebug(this) << "Loaded section" << section.title; + qmlDebug(this) << "Loaded section " << section.title; emit presentSection(_entryFilterModel); } @@ -48,7 +48,7 @@ void SettingsUiBuilder::showDialog(const QString &key, const QString &title, con if(type == QStringLiteral("action")) _viewModel->callAction(key, properties.value(QStringLiteral("args")).toMap()); else { - qmlDebug(this) << "Creating input dialog for settings entry" << key; + qmlDebug(this) << "Creating input dialog for settings entry " << key; getInput(title + tr(":"), QString(), qUtf8Printable(type), this, [this, key](const QVariant &value) { if(value.isValid()) _viewModel->saveValue(key, value);