From e87e8e9e877f039ffec70de7c8d37dd4945c3231 Mon Sep 17 00:00:00 2001 From: Merydian Date: Mon, 15 Jan 2024 13:05:39 +0100 Subject: [PATCH] fix: error when using move mode with empty point list. --- ORStools/gui/ORStoolsDialog.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ORStools/gui/ORStoolsDialog.py b/ORStools/gui/ORStoolsDialog.py index 7ce55654..745b0fd8 100644 --- a/ORStools/gui/ORStoolsDialog.py +++ b/ORStools/gui/ORStoolsDialog.py @@ -561,13 +561,20 @@ def _on_linetool_init(self): self.line_tool.doubleClicked.connect(self._on_linetool_map_doubleclick) def _on_move_vertices_tool_init(self): - self.hide() - self.move_tool = maptools.ShiftTool(self._iface.mapCanvas()) - - self._iface.mapCanvas().setMapTool(self.move_tool) - self.move_tool.pointPressed.connect(lambda point: self._on_movetool_map_press(point)) - self.move_tool.pointReleased.connect(lambda point: self._on_movetool_map_release(point)) - self.move_tool.doubleClicked.connect(self._on_movetool_map_doubleclick) + if self.routing_fromline_list.count() > 0: + self.hide() + self.move_tool = maptools.ShiftTool(self._iface.mapCanvas()) + + self._iface.mapCanvas().setMapTool(self.move_tool) + self.move_tool.pointPressed.connect(lambda point: self._on_movetool_map_press(point)) + self.move_tool.pointReleased.connect(lambda point: self._on_movetool_map_release(point)) + self.move_tool.doubleClicked.connect(self._on_movetool_map_doubleclick) + else: + QMessageBox.warning( + self, + "Empty point list", + """Please add points to move them.""", + ) def _on_movetool_map_press(self, pos): click = Point(pos.x(), pos.y())