Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gui/wxpython/animation/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ def OnHelp(self, event):
RunCommand("g.manual", quiet=True, entry="wxGUI.animation")

def OnCloseWindow(self, event):
if self.controller.timer.IsRunning():
self.controller.timer.Stop()
CleanUp(TMP_DIR)()
self.close(event)

def close(self, event=None):
self.__del__() # noqa: PLC2801, C2801
self._mgr.UnInit()
self.Destroy()

Expand All @@ -366,6 +367,7 @@ def __del__(self):
if self.controller.timer.IsRunning():
self.controller.timer.Stop()
CleanUp(TMP_DIR)()
tgis.stop_subprocesses()


class AnimationsPanel(wx.Panel):
Expand Down
26 changes: 25 additions & 1 deletion gui/wxpython/lmgr/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __init__(

self._giface = LayerManagerGrassInterface(self)

# List of wxGUI tools frames with initilized tgis framework suprocesses
self.framesWithInitTgisSubprocesses = []

# workspace manager
self.workspace_manager = WorkspaceManager(lmgr=self, giface=self._giface)
self._setTitle()
Expand Down Expand Up @@ -1698,6 +1701,7 @@ def OnAnimationTool(self, event=None, cmd=None):
frame = AnimationFrame(parent=self, giface=self._giface)
frame.CentreOnScreen()
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

tree = self.GetLayerTree()
if tree:
Expand Down Expand Up @@ -1725,8 +1729,9 @@ def OnTimelineTool(self, event=None, cmd=None):
except ImportError:
GError(parent=self, message=_("Unable to start Timeline Tool."))
return
frame = TimelineFrame(None)
frame = TimelineFrame(parent=self)
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

def OnTplotTool(self, event=None, cmd=None):
"""Launch Temporal Plot Tool"""
Expand All @@ -1737,6 +1742,7 @@ def OnTplotTool(self, event=None, cmd=None):
return
frame = TplotFrame(parent=self, giface=self._giface)
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

def OnHistogram(self, event):
"""Init histogram display canvas and tools"""
Expand Down Expand Up @@ -2281,6 +2287,7 @@ def OnCloseWindowOrExit(self, event):
if ret != wx.ID_CANCEL:
self._closeWindow(event)
if ret == wx.ID_YES:
self._stopFramesWithInitTgisSubprocesses()
self._quitGRASS()

def _closeWindow(self, event):
Expand All @@ -2301,6 +2308,23 @@ def _closeWindow(self, event):
self._auimgr.UnInit()
self.Destroy()

def _stopFramesWithInitTgisSubprocesses(self):
"""Stop wxGUI tools frames initiallized tgis framework
subprocesses

All these wxGUI Animation, Timeline, Temporal tool initialize tgis
framework (messenger and C-interface subprocesses) which require to be
properly stopped before quitting GRASS (sending SIGTERM signal), because
it causes "freeze" wxGUI tool window and wxGUI processes are not terminated.
"""
try:
for frame in self.framesWithInitTgisSubprocesses:
if frame:
frame.close()
# OSError: handle is closed error
except OSError:
pass

def _quitGRASS(self):
"""Quit GRASS terminal"""
shellPid = get_shell_pid()
Expand Down
26 changes: 25 additions & 1 deletion gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def __init__(

self._giface = LayerManagerGrassInterface(self)

# List of wxGUI tools frames with initilized tgis framework suprocesses
self.framesWithInitTgisSubprocesses = []

# workspace manager
self.workspace_manager = WorkspaceManager(lmgr=self, giface=self._giface)
self._setTitle()
Expand Down Expand Up @@ -1854,6 +1857,7 @@ def OnAnimationTool(self, event=None, cmd=None):
frame = AnimationFrame(parent=self, giface=self._giface)
frame.CentreOnScreen()
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

tree = self.GetLayerTree()
if tree:
Expand Down Expand Up @@ -1881,8 +1885,9 @@ def OnTimelineTool(self, event=None, cmd=None):
except ImportError:
GError(parent=self, message=_("Unable to start Timeline Tool."))
return
frame = TimelineFrame(None)
frame = TimelineFrame(parent=self)
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

def OnTplotTool(self, event=None, cmd=None):
"""Launch Temporal Plot Tool"""
Expand All @@ -1893,6 +1898,7 @@ def OnTplotTool(self, event=None, cmd=None):
return
frame = TplotFrame(parent=self, giface=self._giface)
frame.Show()
self.framesWithInitTgisSubprocesses.append(frame)

def OnHistogram(self, event):
"""Init histogram display canvas and tools"""
Expand Down Expand Up @@ -2390,6 +2396,7 @@ def OnCloseWindowOrExit(self, event):
if ret != wx.ID_CANCEL:
self._closeWindow(event)
if ret == wx.ID_YES:
self._stopFramesWithInitTgisSubprocesses()
self._quitGRASS()

def _closeWindow(self, event):
Expand All @@ -2410,6 +2417,23 @@ def _closeWindow(self, event):
self._auimgr.UnInit()
self.Destroy()

def _stopFramesWithInitTgisSubprocesses(self):
"""Stop wxGUI tools frames initiallized tgis framework
subprocesses

All these wxGUI Animation, Timeline, Temporal tool initialize tgis
framework (messenger and C-interface subprocesses) which require to be
properly stopped before quitting GRASS (sending SIGTERM signal), because
it causes "freeze" wxGUI tool window and wxGUI processes are not terminated.
"""
try:
for frame in self.framesWithInitTgisSubprocesses:
if frame:
frame.close()
# OSError: handle is closed error
except OSError:
pass

def _quitGRASS(self):
"""Quit GRASS terminal"""
shellPid = get_shell_pid()
Expand Down
3 changes: 3 additions & 0 deletions gui/wxpython/timeline/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def __init__(self, parent, title=_("Timeline Tool")):
self.Bind(wx.EVT_CLOSE, self.OnClose)

def OnClose(self, event):
self.close(event)

def close(self, event=None):
"""Close the database interface and stop the messenger and C-interface
subprocesses.
"""
Expand Down
3 changes: 3 additions & 0 deletions gui/wxpython/tplot/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def __del__(self):
tgis.stop_subprocesses()

def onClose(self, evt):
self.close(evt)

def close(self, evt=None):
if self._giface.GetMapDisplay():
self.coorval.OnClose()
self.cats.OnClose()
Expand Down
Loading