Prevent a crash on close

The Destructor of the class Model::Private indirecly called
modelAboutToBeDetached which did lead the FormEditor to try
to access the already deleted ModelPrivate.
This patch is a quick-crash-fix that prevents this by moving
the detachAllViews call from the destructor of ModelPrivate
to the destructor of Model.
Note that a clean fix would probably make the access of
ModelPrivate outside of Model impossible but this is outside
the scope of this fix and left for a later exercise.

Fixes: QDS-7587
Change-Id: I0d03423ae6eaf4d86eddba26ec5edb643ea5a51e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Knud Dollereder
2022-10-26 16:30:59 +02:00
parent aa33927651
commit 211f53ceba

View File

@@ -88,10 +88,7 @@ ModelPrivate::ModelPrivate(
m_currentTimelineNode = m_rootInternalNode;
}
ModelPrivate::~ModelPrivate()
{
detachAllViews();
}
ModelPrivate::~ModelPrivate() = default;
void ModelPrivate::detachAllViews()
{
@@ -1397,7 +1394,11 @@ Model::Model(const TypeName &typeName, int major, int minor, Model *metaInfoProx
: d(std::make_unique<Internal::ModelPrivate>(this, typeName, major, minor, metaInfoProxyModel))
{}
Model::~Model() = default;
Model::~Model()
{
d->detachAllViews();
d.reset(nullptr);
}
const QList<Import> &Model::imports() const
{