[TD]fix segfault on confused selection

- failure in DrawDimHelper when both 2d & 3d geom selected
This commit is contained in:
wandererfan
2024-06-15 19:51:25 -04:00
committed by WandererFan
parent 8b17272abc
commit e31f338a94
3 changed files with 19 additions and 2 deletions

View File

@@ -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.

View File

@@ -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});

View File

@@ -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);
@@ -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());