diff --git a/src/Mod/TechDraw/Gui/DimensionValidators.cpp b/src/Mod/TechDraw/Gui/DimensionValidators.cpp index 6d055d02edc5..b1da5150236e 100644 --- a/src/Mod/TechDraw/Gui/DimensionValidators.cpp +++ b/src/Mod/TechDraw/Gui/DimensionValidators.cpp @@ -119,8 +119,9 @@ DimensionGeometryType TechDraw::validateDimSelection( TechDraw::DrawViewPart* dvp = dynamic_cast(ref.getObject()); if (dvp) { dvpSave = dvp; - //TODO: check for non-empty subname? - subNames.push_back(ref.getSubName()); + if (!ref.getSubName().empty()) { + subNames.push_back(ref.getSubName()); + } } } if (!dvpSave) { @@ -128,12 +129,17 @@ DimensionGeometryType TechDraw::validateDimSelection( return isInvalid; } - if (subNames.front().empty()) { + if (subNames.empty()) { //no geometry referenced. can not make a dim from this mess. We are being called to validate //a selection for a 3d reference return isViewReference; } + if (subNames.front().empty()) { + //can this still happen? + return isViewReference; + } + //check for invalid geometry descriptors in the subNames std::unordered_set acceptableGeometrySet(acceptableGeometry.begin(), acceptableGeometry.end()); @@ -237,11 +243,11 @@ bool TechDraw::checkGeometryOccurences(StringVector subNames, GeomCountMap keyed std::string geometryType = DrawUtil::getGeomTypeFromName(sub); std::map::iterator it0(foundCounts.find(geometryType)); if (it0 == foundCounts.end()) { - //already have this geometryType - it0->second++; - } else { //first occurrence of this geometryType foundCounts[geometryType] = 1; + } else { + //already have this geometryType + it0->second++; } }