From 08cf906218120fcc9d3137dc1872fb30ce32b4a0 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 22 Mar 2017 03:28:12 +0800 Subject: [PATCH] PathGui: fixed potential crash on Path object delete --- src/Mod/Path/Gui/ViewProviderPath.cpp | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index d3672297e2..107ea05b91 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -258,20 +258,25 @@ SoDetail* ViewProviderPath::getDetail(const char* subelement) const } void ViewProviderPath::onSelectionChanged(const Gui::SelectionChanges& msg) { - if(msg.Type == Gui::SelectionChanges::SetPreselect && - msg.pSubName && pt0Index >= 0 && - strcmp(msg.pDocName,getObject()->getDocument()->getName())==0 && - strcmp(msg.pObjectName,getObject()->getNameInDocument())==0) - { - Path::Feature* pcPathObj = static_cast(pcObject); - Base::Vector3d pt = pcPathObj->Placement.getValue().inverse().toMatrix()* - Base::Vector3d(msg.x,msg.y,msg.z); - const SbVec3f &ptTo = *pcLineCoords->point.getValues(pt0Index); - SbVec3f ptFrom(pt.x,pt.y,pt.z); - if(ptFrom != ptTo) { - pcArrowTransform->pointAt(ptFrom,ptTo); - pcArrowSwitch->whichChild = 0; - return; + if(msg.Type == Gui::SelectionChanges::SetPreselect && msg.pSubName && + pt0Index >= 0 && getObject() && getObject()->getDocument()) + { + const char *docName = getObject()->getDocument()->getName(); + const char *objName = getObject()->getNameInDocument(); + if(docName && objName && + strcmp(msg.pDocName,docName)==0 && + strcmp(msg.pObjectName,objName)==0) + { + Path::Feature* pcPathObj = static_cast(pcObject); + Base::Vector3d pt = pcPathObj->Placement.getValue().inverse().toMatrix()* + Base::Vector3d(msg.x,msg.y,msg.z); + const SbVec3f &ptTo = *pcLineCoords->point.getValues(pt0Index); + SbVec3f ptFrom(pt.x,pt.y,pt.z); + if(ptFrom != ptTo) { + pcArrowTransform->pointAt(ptFrom,ptTo); + pcArrowSwitch->whichChild = 0; + return; + } } } pcArrowSwitch->whichChild = -1;