diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 7a44222ec9..adc10d1118 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -111,6 +111,29 @@ void PropertyItem::reset() childItems.clear(); } +void PropertyItem::onChange() +{ + if(hasExpression()) { + for(auto child : childItems) { + if(child && child->hasExpression()) + child->setExpression(boost::shared_ptr()); + } + for(auto item=parentItem;item;item=item->parentItem) { + if(item->hasExpression()) + item->setExpression(boost::shared_ptr()); + } + } +} + +bool PropertyItem::hasAnyExpression() const +{ + if(ExpressionBinding::hasExpression()) + return true; + if(parentItem) + return parentItem->hasExpression(); + return false; +} + void PropertyItem::setPropertyData(const std::vector& items) { //if we have a single property we can bind it for expression handling @@ -581,7 +604,7 @@ bool PropertyItem::setData (const QVariant& value) // property or delegates again to its parent... if (propertyItems.empty()) { PropertyItem* parent = this->parent(); - if (!parent || !parent->parent()) + if (!parent || !parent->parent() || hasAnyExpression()) return false; parent->setProperty(qPrintable(objectName()),value); return true; diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 5bccc400bc..43c7754441 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -164,6 +164,8 @@ public: int row() const; void reset(); + bool hasAnyExpression() const; + protected: PropertyItem(); @@ -176,6 +178,9 @@ protected: virtual void initialize(); QString pythonIdentifier(const App::Property*) const; + //gets called when the bound expression is changed + virtual void onChange(); + protected: QString propName; QString displayText;