QmlDesigner: Fix crash

We have to call  updateEnabledViews() in the correct places.
AbstractView::modelAboutToBeDetached() was to late, since the view
is already removed at this point.

Change-Id: I6d71d5ea773fb7ec8ec258344498a229a30dd9b3
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2020-10-02 12:51:38 +02:00
parent 133da9797e
commit ff99c2213b
2 changed files with 2 additions and 4 deletions

View File

@@ -185,11 +185,7 @@ is removing the reference to the model from the view.
*/ */
void AbstractView::modelAboutToBeDetached(Model *) void AbstractView::modelAboutToBeDetached(Model *)
{ {
Model *oldModel = model();
removeModel(); removeModel();
if (oldModel)
oldModel->d->updateEnabledViews();
} }
/*! /*!

View File

@@ -101,6 +101,7 @@ void ModelPrivate::detachAllViews()
detachView(view.data(), true); detachView(view.data(), true);
m_viewList.clear(); m_viewList.clear();
updateEnabledViews();
if (m_nodeInstanceView) { if (m_nodeInstanceView) {
m_nodeInstanceView->modelAboutToBeDetached(m_q); m_nodeInstanceView->modelAboutToBeDetached(m_q);
@@ -951,6 +952,7 @@ void ModelPrivate::detachView(AbstractView *view, bool notifyView)
if (notifyView) if (notifyView)
view->modelAboutToBeDetached(m_q); view->modelAboutToBeDetached(m_q);
m_viewList.removeOne(view); m_viewList.removeOne(view);
updateEnabledViews();
} }
void ModelPrivate::notifyNodeCreated(const InternalNode::Pointer &newInternalNodePointer) void ModelPrivate::notifyNodeCreated(const InternalNode::Pointer &newInternalNodePointer)