From ff0f8b0d853b4b532deb91f8e303af8001de47f1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 16 Sep 2020 13:41:03 +0200 Subject: [PATCH] Gui: [skip ci] fix crash in DocumentObjectData::updateChildren() when canceling a pending task --- src/Gui/Tree.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 138d1116fbde..56b3a9efce32 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -322,11 +322,17 @@ class Gui::DocumentObjectData { if (newSet.find(child) == newSet.end()) { // this means old child removed updated = true; - docItem->_ParentMap[child].erase(obj); + auto mapIt = docItem->_ParentMap.find(child); - auto childVp = docItem->getViewProvider(child); - if (childVp && child->getDocument() == obj->getDocument()) - childVp->setShowable(docItem->isObjectShowable(child)); + // If 'child' is not part of the map then it has already been deleted + // in _slotDeleteObject. + if (mapIt != docItem->_ParentMap.end()) { + docItem->_ParentMap[child].erase(obj); + + auto childVp = docItem->getViewProvider(child); + if (childVp && child->getDocument() == obj->getDocument()) + childVp->setShowable(docItem->isObjectShowable(child)); + } } } // We still need to check the order of the children