forked from qt-creator/qt-creator
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:
@@ -88,10 +88,7 @@ ModelPrivate::ModelPrivate(
|
|||||||
m_currentTimelineNode = m_rootInternalNode;
|
m_currentTimelineNode = m_rootInternalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPrivate::~ModelPrivate()
|
ModelPrivate::~ModelPrivate() = default;
|
||||||
{
|
|
||||||
detachAllViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelPrivate::detachAllViews()
|
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))
|
: 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
|
const QList<Import> &Model::imports() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user