In Techdraw there is a major undo/redo problem that I want to fix: When changing the properties listed in the View Tab, these changes cannot be undone. But changing properties in the Data tab can be undone.
I searched around in FC’s code to learn how undo/redo is done but cannot find out a brief explanation, not why only the GUI part of Techdraw is affected. Does anybody please have a pointer for me where to look?
Another question: I noticed that the TechDraw dimension dialog does not store any changes so that undo cannot be performed. I thought I have to open a transaction to store the changes made in the dialog for undo, but I see that e.g. the Balloon dialog stores the changes for undo correctly and has no open transaction. So how do I record changes for a task dialog?
AFAIK changes to view properties are not places on the undo/redo stack (BTW I do not know if ‘stack’ is the right word). This applies to ALL workbenches.
It’s not a bug but #4553 can be considered as feature request. In order to make undo/redo working for view properties there are needed only two minor changes in the source code.
In PropertyView.cpp there is this call:
I don’t know why TaskBallon records changes while TaskDimension doesn’t. But both dialogs don’t work correctly because when clicking Cancel the changes must be reverted.
Thanks for having a look. I guess my “mistake” was to just use the existing Balloon dialog to create the dimension dialog. Therefore it inherits all Balloon dialog issues.
I will have a look tonight.
Ah, thanks. Can we please have it turn this on by default since having the undo feature is an improvement for workflow. Or what would tbe the potential disadvantage?
But a bit different than with the Data properties:
I select a sketch in the model tree, then I change a Sketcher View property
I go/click on another property of the sketch
result: undo is not active
I first need to select another item in the model tree, then Undo becomes active
This is different to the Data properties whose changes can directly be undone without the need to select another item in the model tree first.
Ideally the properties should behave the same regarding undo, no matter if they are in the Data or View tab.
We had such discussions many years ago and we decided against to implement Undo/Redo for view changes as it can very quickly fill your undo list. Now that it’s possible I think it still shouldn’t be enabled by default.
Here are two screenshots of what I see, now with a Version: 0.19.23992 (Git) and recompiled FreeCADGui library.
First after selecting another tree item, undo gets active:
With Data properties, Undo is directly active and Undo is active by default. So on a fresh installation, undo is already on and this works fine:
OK, I think the problem is that the buttons of the toolbars are not updated. In the past we used a timer that regularly updated all commands after every 300ms or so and in v0.19 this timer has been removed and instead an update is triggered after changes to a document, activating the main window, …
Unfortunately, there are still cases where a command is not updated when it should be. So, to confirm this guess what happens if you switch to another application with ALT+TAB and then switch back to FreeCAD with ALT+TAB? This is supposed to trigger a GUI update and should then enable the undo button.
I realize the bug is there only with existing files. For new files and also existing files I saved as, the issue does not occur.
Just for the records, here is a recipe to reproduce:
Then there is no undo, it first appears after you select another item in the model tree.
However, it works now as soon as existing files are saved. The important thing for me is that Undo works by default for the View tab. For the Data tab this is already the case and obviously this has been proven useful.
The undo/redo is controlled by user settings only and not the content of project files. When you create a new document with a box, save, close and reload it and then change a view property you will see the same problem again.
The point is that after loading a project file the undo/redo buttons are disabled because nothing in the document has changed. If you now change a view property the undo button is not updated and thus it’s still disabled. If you switch to another application and back to FreeCAD an update is triggered and the button becomes active.
The reason why it fails for view properties but works with data properties is that for data properties a lot more things are done and at some point an update of the GUI is triggered.
To test
Create a new document and an object (e.g. a box). You will get an active undo button