From f25e6e4716fb63ef3ac618ce9e552761bbc1b4b1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Sep 2014 11:43:51 +0200 Subject: [PATCH] 0001714: FreeCAD 0.14 Stable crashes when importing a step model --- src/Gui/Application.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 1f5777589..a3221d386 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -214,11 +214,19 @@ void ObjectLabelObserver::slotRelabelObject(const App::DocumentObject& obj, cons } // make sure that there is a name conflict otherwise we don't have to do anything - if (match) { + if (match && !label.empty()) { // remove number from end to avoid lengthy names size_t lastpos = label.length()-1; - while (label[lastpos] >= 48 && label[lastpos] <= 57) + while (label[lastpos] >= 48 && label[lastpos] <= 57) { + // if 'lastpos' becomes 0 then all characters are digits. In this case we use + // the complete label again + if (lastpos == 0) { + lastpos = label.length()-1; + break; + } lastpos--; + } + label = label.substr(0, lastpos+1); label = Base::Tools::getUniqueName(label, objectLabels, 3); this->current = &obj;