aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2022-10-27 12:17:22 +0200
committerTim Jenssen <tim.jenssen@qt.io>2022-10-27 14:48:31 +0000
commit2bbae7d499d16566f295a56682fef7d68f064a63 (patch)
tree03ad9726321031a6f9505b192ae42bd17c5f50b6 /tests
parent211f53cebae66608f080e856c3bb8ec1b3136e7c (diff)
QmlDesigner: Detach views outside of model destructor
modelAboutToBeDetached can still calling the model. So calling the function from inside the model destructor is a little bit undefined. To get around it we add a custom delete which call the detachAllViews() before it deletes the model. Change-Id: I38ff8283f4e1ac48b256aeb9fd5bb9f3fb6bfed1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp8
-rw-r--r--tests/unit/unittest/listmodeleditor-test.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
index cc29b586524..e57c4aac0f2 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
@@ -166,10 +166,10 @@ public:
Model &model;
};
-std::unique_ptr<QmlDesigner::Model> createModel(const QString &typeName,
- int major = 2,
- int minor = 1,
- Model *metaInfoPropxyModel = 0)
+ModelPointer createModel(const QString &typeName,
+ int major = 2,
+ int minor = 1,
+ Model *metaInfoPropxyModel = 0)
{
QApplication::processEvents();
diff --git a/tests/unit/unittest/listmodeleditor-test.cpp b/tests/unit/unittest/listmodeleditor-test.cpp
index 9b12adc0030..bde9b747003 100644
--- a/tests/unit/unittest/listmodeleditor-test.cpp
+++ b/tests/unit/unittest/listmodeleditor-test.cpp
@@ -175,7 +175,7 @@ public:
protected:
MockFunction<ModelNode(const ModelNode &)> mockGoIntoComponent;
- std::unique_ptr<QmlDesigner::Model> designerModel{QmlDesigner::Model::create("QtQuick.Item", 1, 1)};
+ QmlDesigner::ModelPointer designerModel{QmlDesigner::Model::create("QtQuick.Item", 1, 1)};
NiceMock<MockListModelEditorView> mockView;
QmlDesigner::ListModelEditorModel model{
[&] { return mockView.createModelNode("QtQml.Models.ListModel", 2, 15); },
@@ -187,7 +187,7 @@ protected:
ModelNode element1;
ModelNode element2;
ModelNode element3;
- std::unique_ptr<QmlDesigner::Model> componentModel{
+ QmlDesigner::ModelPointer componentModel{
QmlDesigner::Model::create("QtQml.Models.ListModel", 1, 1)};
NiceMock<MockListModelEditorView> mockComponentView;
ModelNode componentElement;