Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [WB Draft] Undo doesn't work after using Move function on lines created in Draft WB #8044

Closed
2 tasks done
acp693 opened this issue Dec 14, 2022 · 6 comments · Fixed by #8267
Closed
2 tasks done
Assignees
Labels
Bug This issue or PR is related to a bug OS: Windows Regression Bugs describing a regression or PRs fixing one UI/UX Undo/Redo Issues and PRs related to the undo mechanism WB Draft Related to the Draft Workbench

Comments

@acp693
Copy link

acp693 commented Dec 14, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Forums discussion

https://forum.freecadweb.org/viewtopic.php?f=3&t=74424

Version

0.21 (Development)

Full version info

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.31109 (Git)
Build type: Release
Branch: master
Hash: c23ee7ad88433a0f00e84afae0a62fe738be0c09
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods: 
  * CurvedShapes 1.0.4
  * Curves 0.5.3
  * FeedsAndSpeeds 0.5.0
  * Marz 0.0.26-alpha
  * Silk 1.0.0

Subproject(s) affected?

Draft

Issue description

Create a line in Draft WB. Use the Move function in Draft WB to move the line and then press undo (ctrl Z), the line doesn't move back to it's original position. However, other objects not created in Draft WB do move back to their original positions such as primitives created in Part WB when the undo function is used. It seems to be lines, splines etc. created in Draft WB that aren't working properly.

This seems to be potentially just a windows problem. Another user, DrMarco, reported correct behaviour from a Linux installation of Freecad.

The problem occurs on the latest development version of Freecad 0.21.31109 and the stable version(0.20.1)

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chennes chennes added the WB Draft Related to the Draft Workbench label Dec 17, 2022
@luzpaz luzpaz added Bug This issue or PR is related to a bug Undo/Redo Issues and PRs related to the undo mechanism labels Dec 20, 2022
@luzpaz
Copy link
Contributor

luzpaz commented Dec 29, 2022

@Roy-043 can you test when you get a chance? (Also there is a rotate bug not sure it's DraftWB related). This may be just a Windows issues, btw

@Roy-043
Copy link
Contributor

Roy-043 commented Dec 30, 2022

First of all, I can only confirm this.

The issue seems related to the code used in the execute function of the Wire object class. This function is triggered by a recompute inside the move transaction. This somehow 'breaks' undo-redo. There are two potential solutions:

  1. Remove/fix the problem code in the execute function.
  2. Do not recompute inside the transaction, but do so after the transaction has been committed.

See test codes below. The only difference between the two is the position of doc.recompute().

Test code "undo_problem":

import FreeCAD as App
import Draft

doc = App.ActiveDocument

p1 = App.Vector(0, 0, 0)
p2 = App.Vector(10, 10, 0)
line = Draft.make_line(p1, p2)
doc.recompute()

delta = App.Vector(20, 0, 0)

doc.openTransaction("undo_problem")
Draft.move(line, delta, copy=False)
doc.recompute()
doc.commitTransaction()

Test code "undo_ok":

import FreeCAD as App
import Draft

doc = App.ActiveDocument

p1 = App.Vector(0, 0, 0)
p2 = App.Vector(10, 10, 0)
line = Draft.make_line(p1, p2)
doc.recompute()

delta = App.Vector(20, 0, 0)

doc.openTransaction("undo_ok")
Draft.move(line, delta, copy=False)
doc.commitTransaction()
doc.recompute()

@Roy-043 Roy-043 self-assigned this Dec 30, 2022
@Roy-043 Roy-043 added the Regression Bugs describing a regression or PRs fixing one label Dec 30, 2022
@Roy-043
Copy link
Contributor

Roy-043 commented Dec 30, 2022

This is a regression introduced in V0.19.

@Roy-043
Copy link
Contributor

Roy-043 commented Dec 31, 2022

Since the issue also occurs if you change the Placement of a Draft_Line in the Property editor, the solution probably must be found in the execute function. What is strange is that this function has not been changed since V0.18, and in V0.18 the issue does not occur, either with Draft.move, or when directly changing the Placement of the object. This suggests that the cause may involve more than just the code from the Draft Workbench.

@wwmayer
Copy link
Contributor

wwmayer commented Jan 1, 2023

@Roy-043
Copy link
Contributor

Roy-043 commented Jan 7, 2023

Here are files that implement the workaround mentioned in the second forum thread: avoid the creation of a new Shape if only the Placement is changed.
https://forum.freecadweb.org/viewtopic.php?f=10&t=74920

Instructions:

  1. Make backups of ../Mod/Draft/draftfunctions/ and ../Mod/Draft/draftobjects/.
  2. Unpack draftfunctions.zip and draftobjects.zip in the correct folder.
  3. Restarts FreeCAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue or PR is related to a bug OS: Windows Regression Bugs describing a regression or PRs fixing one UI/UX Undo/Redo Issues and PRs related to the undo mechanism WB Draft Related to the Draft Workbench
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants