diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h index 6f9d6014e97..0792a635ca3 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h @@ -60,10 +60,13 @@ private: MaterialEditorView *materialEditor); PropertyName auxNamePostFix(const PropertyName &propertyName); + // to avoid a crash while destructing DesignerPropertyMap in the QQmlData + // this needs be destructed after m_quickWidget->engine() is destructed + DesignerPropertyMap m_backendValuesPropertyMap; + Utils::UniqueObjectPtr m_quickWidget = nullptr; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - DesignerPropertyMap m_backendValuesPropertyMap; QScopedPointer m_materialEditorTransaction; QScopedPointer m_contextObject; QPointer m_materialEditorImageProvider; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 6f3242a18e9..eea53c3f5a1 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -82,10 +82,10 @@ namespace QmlDesigner { PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyEditor, AsynchronousImageCache &imageCache) - : m_view(new Quick2PropertyEditorView(imageCache)) + : m_view(Utils::makeUniqueObjectPtr(imageCache)) , m_propertyEditorTransaction(new PropertyEditorTransaction(propertyEditor)) , m_dummyPropertyEditorValue(new PropertyEditorValue()) - , m_contextObject(new PropertyEditorContextObject(m_view)) + , m_contextObject(new PropertyEditorContextObject(m_view.get())) { m_view->engine()->setOutputWarningsToStandardError(QmlDesignerPlugin::instance() ->settings().value(DesignerSettingsKey::SHOW_PROPERTYEDITOR_WARNINGS).toBool()); @@ -407,7 +407,7 @@ PropertyEditorContextObject *PropertyEditorQmlBackend::contextObject() QQuickWidget *PropertyEditorQmlBackend::widget() { - return m_view; + return m_view.get(); } void PropertyEditorQmlBackend::setSource(const QUrl &url) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h index d4e158fca4e..120b7b4abcf 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h @@ -10,6 +10,8 @@ #include "qmlmodelnodeproxy.h" #include "quick2propertyeditorview.h" +#include + #include #include @@ -100,10 +102,13 @@ private: static TypeName fixTypeNameForPanes(const TypeName &typeName); private: - Quick2PropertyEditorView *m_view; + // to avoid a crash while destructing DesignerPropertyMap in the QQmlData + // this needs be destructed after m_quickWidget->engine() is destructed + DesignerPropertyMap m_backendValuesPropertyMap; + + Utils::UniqueObjectPtr m_view = nullptr; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - DesignerPropertyMap m_backendValuesPropertyMap; QScopedPointer m_propertyEditorTransaction; QScopedPointer m_dummyPropertyEditorValue; QScopedPointer m_contextObject; diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp index 80cf5693d28..972574554b0 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp @@ -43,17 +43,17 @@ static QObject *variantToQObject(const QVariant &value) namespace QmlDesigner { TextureEditorQmlBackend::TextureEditorQmlBackend(TextureEditorView *textureEditor, AsynchronousImageCache &imageCache) - : m_view(new QQuickWidget) + : m_quickWidget(new QQuickWidget) , m_textureEditorTransaction(new TextureEditorTransaction(textureEditor)) - , m_contextObject(new TextureEditorContextObject(m_view->rootContext())) + , m_contextObject(new TextureEditorContextObject(m_quickWidget->rootContext())) { QImage defaultImage; defaultImage.load(Utils::StyleHelper::dpiSpecificImageFile(":/textureeditor/images/texture_default.png")); m_textureEditorImageProvider = new AssetImageProvider(imageCache, defaultImage); - m_view->setResizeMode(QQuickWidget::SizeRootObjectToView); - m_view->setObjectName(Constants::OBJECT_NAME_TEXTURE_EDITOR); - m_view->engine()->addImportPath(propertyEditorResourcesPath() + "/imports"); - m_view->engine()->addImageProvider("qmldesigner_thumbnails", m_textureEditorImageProvider); + m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); + m_quickWidget->setObjectName(Constants::OBJECT_NAME_TEXTURE_EDITOR); + m_quickWidget->engine()->addImportPath(propertyEditorResourcesPath() + "/imports"); + m_quickWidget->engine()->addImageProvider("qmldesigner_thumbnails", m_textureEditorImageProvider); m_contextObject->setBackendValues(&m_backendValuesPropertyMap); m_contextObject->setModel(textureEditor->model()); context()->setContextObject(m_contextObject.data()); @@ -154,7 +154,7 @@ void TextureEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyName QQmlContext *TextureEditorQmlBackend::context() const { - return m_view->rootContext(); + return m_quickWidget->rootContext(); } TextureEditorContextObject *TextureEditorQmlBackend::contextObject() const @@ -164,12 +164,12 @@ TextureEditorContextObject *TextureEditorQmlBackend::contextObject() const QQuickWidget *TextureEditorQmlBackend::widget() const { - return m_view; + return m_quickWidget.get(); } void TextureEditorQmlBackend::setSource(const QUrl &url) { - m_view->setSource(url); + m_quickWidget->setSource(url); } QmlAnchorBindingProxy &TextureEditorQmlBackend::backendAnchorBinding() diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h index b6d3fddf22d..c8a113f7d3d 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h @@ -7,6 +7,8 @@ #include "qmlanchorbindingproxy.h" #include "qmlmodelnodeproxy.h" +#include + #include class PropertyEditorValue; @@ -58,10 +60,13 @@ private: TextureEditorView *textureEditor); PropertyName auxNamePostFix(const PropertyName &propertyName); - QQuickWidget *m_view = nullptr; + // to avoid a crash while destructing DesignerPropertyMap in the QQmlData + // this needs be destructed after m_quickWidget->engine() is destructed + DesignerPropertyMap m_backendValuesPropertyMap; + + Utils::UniqueObjectPtr m_quickWidget = nullptr; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - DesignerPropertyMap m_backendValuesPropertyMap; QScopedPointer m_textureEditorTransaction; QScopedPointer m_contextObject; AssetImageProvider *m_textureEditorImageProvider = nullptr;