App: fix property ordering problem when undo/redo (#3255)
* Part: fix Placement/Shape onChanged() handling * App: fix property ordering problem when undo/redo See https://tracker.freecadweb.org/view.php?id=4265#c14271 * Gui: fix undo/redo signaling Make sure to signal after all properties has been restored
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Rotation.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/FeaturePythonPyImp.h>
|
||||
#include <App/Document.h>
|
||||
@@ -540,8 +541,17 @@ void Feature::onChanged(const App::Property* prop)
|
||||
{
|
||||
// if the placement has changed apply the change to the point data as well
|
||||
if (prop == &this->Placement) {
|
||||
TopoShape& shape = const_cast<TopoShape&>(this->Shape.getShape());
|
||||
// The following code bypasses transaction, which may cause problem to
|
||||
// undo/redo
|
||||
//
|
||||
// TopoShape& shape = const_cast<TopoShape&>(this->Shape.getShape());
|
||||
// shape.setTransform(this->Placement.getValue().toMatrix());
|
||||
|
||||
TopoShape shape = this->Shape.getShape();
|
||||
shape.setTransform(this->Placement.getValue().toMatrix());
|
||||
Base::ObjectStatusLocker<App::Property::Status, App::Property> guard(
|
||||
App::Property::NoRecompute, &this->Shape);
|
||||
this->Shape.setValue(shape);
|
||||
}
|
||||
// if the point data has changed check and adjust the transformation as well
|
||||
else if (prop == &this->Shape) {
|
||||
@@ -554,8 +564,7 @@ void Feature::onChanged(const App::Property* prop)
|
||||
// shape must not be null to override the placement
|
||||
if (!this->Shape.getValue().IsNull()) {
|
||||
p.fromMatrix(this->Shape.getShape().getTransform());
|
||||
if (p != this->Placement.getValue())
|
||||
this->Placement.setValue(p);
|
||||
this->Placement.setValueIfChanged(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user