Skip to content
Permalink
Browse files

Fix Shape Binder crash when nothing selected first

Partially resolves issue #2517
  • Loading branch information...
peterlama authored and wwmayer committed Sep 10, 2017
1 parent 832e186 commit 756ed3381e65e9744790710c4a6338a64394e93e
Showing with 23 additions and 5 deletions.
  1. +23 −5 src/Mod/PartDesign/Gui/TaskShapeBinder.cpp
@@ -226,18 +226,34 @@ bool TaskShapeBinder::referenceSelected(const SelectionChanges& msg) const {
//change the references
std::string subName(msg.pSubName);

Part::Feature* selectedObj = nullptr;
Part::Feature* obj = nullptr;
std::vector<std::string> refs;

PartDesign::ShapeBinder::getFilteredReferences(&static_cast<PartDesign::ShapeBinder*>(vp->getObject())->Support, obj, refs);

//if we already have a object we need to ensure th new selected subref belongs to it
if(obj && strcmp(msg.pObjectName, obj->getNameInDocument()) != 0)

// get selected object
auto docObj = vp->getObject()->getDocument()->getObject(msg.pObjectName);
if (docObj && docObj->isDerivedFrom(Part::Feature::getClassTypeId())) {
selectedObj = static_cast<Part::Feature*>(docObj);
}

// ensure we have a valid object
if (!selectedObj) {
return false;

std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
}
if (!obj) {
// Support has not been set before
obj = selectedObj;
}

if(selectionMode != refObjAdd) {
// ensure the new selected subref belongs to the same object
if (strcmp(msg.pObjectName, obj->getNameInDocument()) != 0)
return false;

std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);

if (selectionMode == refAdd) {
if (f == refs.end())
refs.push_back(subName);
@@ -251,7 +267,9 @@ bool TaskShapeBinder::referenceSelected(const SelectionChanges& msg) const {
}
}
else {
// change object
refs.clear();
obj = selectedObj;
}

static_cast<PartDesign::ShapeBinder*>(vp->getObject())->Support.setValue(obj, refs);

0 comments on commit 756ed33

Please sign in to comment.
You can’t perform that action at this time.