From 4a2190f8357bfbaea43ade365b77e4b27b2cc565 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 17 Apr 2024 09:59:27 +0200 Subject: [PATCH] Gui: In Placement dialog check that the object identifier has a valid property before binding it to a widget --- src/Gui/Placement.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index ef8db1fb0c..372a80f3fa 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -115,7 +115,7 @@ void PlacementHandler::openTransactionIfNeeded() void PlacementHandler::setPropertyName(const std::string& name) { propertyName = name; - // Only the Placement property it's possible to directly change the Inventor representation. + // Only with the Placement property it's possible to directly change the Inventor representation. // For other placement properties with a different name the standard property handling must be used. changeProperty = (propertyName != "Placement"); } @@ -786,22 +786,25 @@ void Placement::bindObject() App::DocumentObject* obj = selectionObjects.front().getObject(); std::string propertyName = handler.getPropertyName(); - ui->xPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.x"))); - ui->yPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.y"))); - ui->zPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.z"))); + App::ObjectIdentifier path = App::ObjectIdentifier::parse(obj, propertyName); + if (path.getProperty()) { + ui->xPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.x"))); + ui->yPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.y"))); + ui->zPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.z"))); - ui->xAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.x"))); - ui->yAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.y"))); - ui->zAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.z"))); - ui->angle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Angle"))); + ui->xAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.x"))); + ui->yAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.y"))); + ui->zAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.z"))); + ui->angle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Angle"))); - ui->yawAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Yaw"))); - ui->pitchAngle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Pitch"))); - ui->rollAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Roll"))); + ui->yawAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Yaw"))); + ui->pitchAngle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Pitch"))); + ui->rollAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Roll"))); - ui->yawAngle->evaluateExpression(); - ui->pitchAngle->evaluateExpression(); - ui->rollAngle->evaluateExpression(); + ui->yawAngle->evaluateExpression(); + ui->pitchAngle->evaluateExpression(); + ui->rollAngle->evaluateExpression(); + } } }