From 29ae8b0502d34946b776cd6fcea43e1d085f857d Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 12 Jan 2022 14:44:35 +0100 Subject: [PATCH] Gui: remove obsolete/incorrect tree view comments It's part of the suggestion of this forum post: https://forum.freecadweb.org/viewtopic.php?p=560433#p560433 --- src/Gui/Tree.cpp | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index a4f35ac27c..ce3e79138c 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -3384,32 +3384,8 @@ bool DocumentItem::createNewItem(const Gui::ViewProviderDocumentObject& obj, } ViewProviderDocumentObject* DocumentItem::getViewProvider(App::DocumentObject* obj) { - // Note: It is possible that we receive an invalid pointer from - // claimChildren(), e.g. if multiple properties were changed in - // a transaction and slotChangedObject() is triggered by one - // property being reset before the invalid pointer has been - // removed from another. Currently this happens for - // PartDesign::Body when cancelling a new feature in the dialog. - // First the new feature is deleted, then the Tip property is - // reset, but claimChildren() accesses the Model property which - // still contains the pointer to the deleted feature - // - // return obj && obj->getNameInDocument() && pDocument->isIn(obj); - // - // TODO: is the above isIn() check still necessary? Will - // getNameInDocument() check be sufficient? - - - if (!obj || !obj->getNameInDocument()) return 0; - - ViewProvider* vp; - if (obj->getDocument() == pDocument->getDocument()) - vp = pDocument->getViewProvider(obj); - else - vp = Application::Instance->getViewProvider(obj); - if (!vp || !vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) - return 0; - return static_cast(vp); + return Base::freecad_dynamic_cast( + Application::Instance->getViewProvider(obj)); } void TreeWidget::slotDeleteDocument(const Gui::Document& Doc)