Skip to content

Commit

Permalink
Draft: Draft_Split fix unhandled exception (#14059)
Browse files Browse the repository at this point in the history
Fixes #13951.

Regression introduced by #12261.
  • Loading branch information
Roy-043 committed May 16, 2024
1 parent 3348636 commit fa79c9d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Mod/Draft/draftguitools/gui_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,27 @@

import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import DraftVecUtils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils

from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftutils.messages import _toolmsg
from draftutils.translate import translate

# The module is used to prevent complaints from code checkers (flake8)
True if Draft_rc.__name__ else False


class Split(gui_base_original.Modifier):
"""Gui Command for the Split tool."""

def GetResources(self):
"""Set icon, menu and tooltip."""

return {'Pixmap': 'Draft_Split',
'Accel': "S, P",
'MenuText': QT_TRANSLATE_NOOP("Draft_Split", "Split"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_Split", "Splits the selected line or polyline into two independent lines\nor polylines by clicking anywhere along the original object.\nIt works best when choosing a point on a straight segment and not a corner vertex.")}
return {"Pixmap": "Draft_Split",
"Accel": "S, P",
"MenuText": QT_TRANSLATE_NOOP("Draft_Split", "Split"),
"ToolTip": QT_TRANSLATE_NOOP("Draft_Split", "Splits the selected line or polyline into two independent lines\nor polylines by clicking anywhere along the original object.\nIt works best when choosing a point on a straight segment and not a corner vertex.")}

Check warning on line 52 in src/Mod/Draft/draftguitools/gui_split.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (273/100) (line-too-long)

def Activated(self):

Check warning on line 54 in src/Mod/Draft/draftguitools/gui_split.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Number of parameters was 3 in 'Modifier.Activated' and is now 1 in overriding 'Split.Activated' method (arguments-differ)
"""Execute when the command is called."""
super(Split, self).Activated(name="Split")
super().Activated(name="Split")
if not self.ui:
return
_toolmsg(translate("draft", "Click anywhere on a line to split it."))
Expand All @@ -85,7 +80,7 @@ def action(self, arg):
and arg["Button"] == "BUTTON1"
and arg["State"] == "DOWN"):
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg)

Check warning on line 82 in src/Mod/Draft/draftguitools/gui_split.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Unused variable 'ctrlPoint' (unused-variable)

Check warning on line 82 in src/Mod/Draft/draftguitools/gui_split.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Attribute 'point' defined outside __init__ (attribute-defined-outside-init)
if "Edge" in info["Component"]:
if info is not None and "Edge" in info["Component"]:
return self.proceed(info)

def proceed(self, info):
Expand All @@ -109,6 +104,11 @@ def proceed(self, info):

self.finish()

def finish(self, cont=False):
"""Terminate the operation."""
self.end_callbacks(self.call)
super().finish()


Gui.addCommand('Draft_Split', Split())

Expand Down

0 comments on commit fa79c9d

Please sign in to comment.