Draft: fix 2 edit mode issues

This commit is contained in:
Roy-043
2021-09-23 20:16:53 +02:00
committed by GitHub
parent 00bb1d0b58
commit 0c92514464

View File

@@ -388,15 +388,15 @@ class ViewProviderDraft(object):
None if mode is not zero.
It is `False` otherwise.
"""
if mode == 0 and App.GuiUp: #remove guard after splitting every viewprovider
if mode != 0:
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
elif 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
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.
@@ -423,7 +423,7 @@ class ViewProviderDraft(object):
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
@@ -432,6 +432,8 @@ class ViewProviderDraft(object):
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