forked from qt-creator/qt-creator
QmlDesigner: fix crash on exit
- use Utils::UniqueObjectPtr because it is a widget and
can get a parent which deletes it
- delete the DesignerPropertyMap as last, so there is no
connection to QmlEngine objects
- renamed view -> widget, where it was easy to rename it
Task-number: QDS-12480
Change-Id: I260909f2965f2943a9693b00876efcbb385d4259
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
(cherry picked from commit 10f855f3f0
)
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -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<QQuickWidget> m_quickWidget = nullptr;
|
||||
QmlAnchorBindingProxy m_backendAnchorBinding;
|
||||
QmlModelNodeProxy m_backendModelNode;
|
||||
DesignerPropertyMap m_backendValuesPropertyMap;
|
||||
QScopedPointer<MaterialEditorTransaction> m_materialEditorTransaction;
|
||||
QScopedPointer<MaterialEditorContextObject> m_contextObject;
|
||||
QPointer<MaterialEditorImageProvider> m_materialEditorImageProvider;
|
||||
|
@@ -82,10 +82,10 @@ namespace QmlDesigner {
|
||||
|
||||
PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyEditor,
|
||||
AsynchronousImageCache &imageCache)
|
||||
: m_view(new Quick2PropertyEditorView(imageCache))
|
||||
: m_view(Utils::makeUniqueObjectPtr<Quick2PropertyEditorView>(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)
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include "qmlmodelnodeproxy.h"
|
||||
#include "quick2propertyeditorview.h"
|
||||
|
||||
#include <utils/uniqueobjectptr.h>
|
||||
|
||||
#include <nodemetainfo.h>
|
||||
|
||||
#include <QQmlPropertyMap>
|
||||
@@ -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<Quick2PropertyEditorView> m_view = nullptr;
|
||||
QmlAnchorBindingProxy m_backendAnchorBinding;
|
||||
QmlModelNodeProxy m_backendModelNode;
|
||||
DesignerPropertyMap m_backendValuesPropertyMap;
|
||||
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
|
||||
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
|
||||
QScopedPointer<PropertyEditorContextObject> m_contextObject;
|
||||
|
@@ -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()
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include "qmlanchorbindingproxy.h"
|
||||
#include "qmlmodelnodeproxy.h"
|
||||
|
||||
#include <utils/uniqueobjectptr.h>
|
||||
|
||||
#include <nodemetainfo.h>
|
||||
|
||||
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<QQuickWidget> m_quickWidget = nullptr;
|
||||
QmlAnchorBindingProxy m_backendAnchorBinding;
|
||||
QmlModelNodeProxy m_backendModelNode;
|
||||
DesignerPropertyMap m_backendValuesPropertyMap;
|
||||
QScopedPointer<TextureEditorTransaction> m_textureEditorTransaction;
|
||||
QScopedPointer<TextureEditorContextObject> m_contextObject;
|
||||
AssetImageProvider *m_textureEditorImageProvider = nullptr;
|
||||
|
Reference in New Issue
Block a user