Skip to content

Commit

Permalink
Merge pull request #5058 from Roy-043/Draft-fix-2-edit-mode-issues
Browse files Browse the repository at this point in the history
Draft: fix 2 edit mode issues
  • Loading branch information
chennes committed Sep 24, 2021
2 parents 5d4f7e9 + 6babbda commit 0e03427
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Mod/Draft/draftviewproviders/view_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,17 @@ def setEdit(self, vobj, mode=0):
None if mode is not zero.
It is `False` otherwise.
"""
if mode == 0 and App.GuiUp: #remove guard after splitting every viewprovider
Gui.runCommand("Draft_Edit")
return True
elif mode != 0:
if mode != 0:
# Act like this function doesn't even exist, so the command falls back to Part (e.g. in the
# case of an unrecognized context menu action)
return None

return False
return None
elif App.GuiUp and "Draft_Edit" in Gui.listCommands(): # remove App.GuiUp guard after splitting every viewprovider
Gui.runCommand("Draft_Edit")
return True
else:
_wrn = "Please load the Draft Workbench to enable editing this object"
App.Console.PrintWarning(QT_TRANSLATE_NOOP("Draft", _wrn))
return False

def unsetEdit(self, vobj, mode=0):
"""Terminate the edit mode of the object.
Expand All @@ -423,7 +425,7 @@ def unsetEdit(self, vobj, mode=0):
This is `obj.ViewObject`.
mode : int, optional
It defaults to 0. It is not used.
It defaults to 0.
It indicates the type of edit in the underlying C++ code.
Returns
Expand All @@ -432,6 +434,8 @@ def unsetEdit(self, vobj, mode=0):
This method always returns `False` so it passes
control to the base class to finish the edit mode.
"""
if mode != 0:
return False
if App.activeDraftCommand:
App.activeDraftCommand.finish()
if App.GuiUp: # remove guard after splitting every viewprovider
Expand Down

0 comments on commit 0e03427

Please sign in to comment.