From 4f5534a87a7e2d224022ff98729a341bf57e7f9e Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 9 Jun 2015 21:55:35 +0200 Subject: [PATCH] + fixes #0002116: FreeCAD crash when I click on treeview --- src/Gui/propertyeditor/PropertyItem.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 1b5f2d4ef..47932bb37 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1706,14 +1706,12 @@ QVariant PropertyEnumItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())); const App::PropertyEnumeration* prop_enum = static_cast(prop); - if (prop_enum->getEnums() == 0) { + const std::vector& value = prop_enum->getEnumVector(); + long currentItem = prop_enum->getValue(); + + if (currentItem < 0 || currentItem >= value.size()) return QVariant(QString()); - } - else { - const std::vector& value = prop_enum->getEnumVector(); - long currentItem = prop_enum->getValue(); - return QVariant(QString::fromUtf8(value[currentItem].c_str())); - } + return QVariant(QString::fromUtf8(value[currentItem].c_str())); } void PropertyEnumItem::setValue(const QVariant& value)