Skip to content

Commit

Permalink
[TD]fix segfault on confused selection
Browse files Browse the repository at this point in the history
- failure in DrawDimHelper when both 2d & 3d geom selected
  • Loading branch information
WandererFan committed Jun 16, 2024
1 parent b565e72 commit 6b84b65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Mod/TechDraw/App/DrawDimHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ DrawDimHelper::minMax3d(DrawViewPart* dvp, ReferenceVector references, int direc
TopoDS_Compound comp;
builder.MakeCompound(comp);
for (auto& ref : references) {
builder.Add(comp, ref.getGeometry());
auto tempGeom = ref.getGeometry();
if (tempGeom.IsNull()) {
continue;
}
builder.Add(comp, tempGeom);
}
Base::Vector3d centroid = dvp->getOriginalCentroid();
TopoDS_Shape centeredShape =//this result is a throw away. We will work with comp.
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/TechDraw/Gui/CommandCreateDims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,19 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
TechDraw::DrawViewPart* partFeat =
TechDraw::getReferencesFromSelection(references2d, references3d);

// if sticky selection is in use we may get confusing selections that appear to
// include both 2d and 3d geometry for the extent dim.
if (!references3d.empty()) {
for (auto& ref : references2d) {
if (!ref.getSubName().empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Incorrect selection"),
QObject::tr("Selection contains both 2d and 3d geometry"));
return;
}
}
}

//Define the geometric configuration required for a extent dimension
StringVector acceptableGeometry({"Edge"});
std::vector<int> minimumCounts({1});
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/DimensionValidators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ TechDraw::DrawViewPart* TechDraw::getReferencesFromSelection(ReferenceVector& re
//subName to a null string to avoid later misunderstandings.
ReferenceEntry ref(dvp, std::string());
references2d.push_back(ref);
continue;
}
for (auto& sub : selItem.getSubNames()) {
ReferenceEntry ref(dvp, sub);
Expand Down Expand Up @@ -192,7 +193,6 @@ DimensionGeometryType TechDraw::validateDimSelection3d(
}
}


//check for invalid geometry descriptors in the subNames
std::unordered_set<std::string> acceptableGeometrySet(acceptableGeometry.begin(),
acceptableGeometry.end());
Expand Down

0 comments on commit 6b84b65

Please sign in to comment.