Opened 6 years ago

Closed 5 years ago

#3607 closed defect (fixed)

Removing map layer crashes wxGUI

Reported by: cmbarton Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: wxGUI Version: git-releasebranch78
Keywords: remove layer, layer manager Cc:
CPU: OSX/Intel Platform: MacOSX

Description

If you try to remove a raster or vector map from the layer manager, using the "remove" option in the popup list launched by the button on the right side of the layer, it will crash the entire GUI with the following error:

/Applications/GRASS-7.5.app/Contents/Resources/bin/pythonw: line 3: 25590 Segmentation fault: 11 /Applications/GRASS-7.5.app/Contents/Resources/python.app/Contents/MacOS/python "$@"

This error and behavior is similar to those reported in #3472 and #3487. This was reported to me for v. 7.4.0 but also occurs in the most recent trunk (r73007)

Attachments (1)

3607_debug_log_2020-03-12.txt (14.5 KB ) - added by nila 5 years ago.
backtrace log up to crash

Download all attachments as: .zip

Change History (16)

comment:1 by cmbarton, 6 years ago

Milestone: 7.4.2

comment:2 by annakrat, 6 years ago

I can't test myself now, but this seems weird. Does this happen every time? Do you have at the same time vector digitizer or 3D view on?

comment:3 by cmbarton, 6 years ago

Every time, but only if removed in this way. All other remove methods work fine.

comment:4 by neteler, 6 years ago

Milestone: 7.4.27.4.3

Ticket retargeted after milestone closed

comment:5 by martinl, 6 years ago

Milestone: 7.4.37.4.4

Bump milestone to 7.4.4

comment:6 by neteler, 6 years ago

Milestone: 7.4.47.4.5

Ticket retargeted after milestone closed

comment:7 by nila, 5 years ago

This is still an issue with 7.8 branch and master (7.9.dev), with Python 3.8.2 and wxPython 4.0.7.post2.

comment:8 by annakrat, 5 years ago

Just to make it clear, do you have to press the button to crash, or also right click (or whatever you use on mac) would do it as well?

comment:9 by nila, 5 years ago

Yes, this only crashes when removing layer from button-menu.

But not from contextual menu (right click), where it works as expected.

by nila, 5 years ago

backtrace log up to crash

comment:10 by nila, 5 years ago

I managed to find the cause of this bug (see attachment above). In short:

  1. clicking the button triggers an event with the GenBitmapButton embedded
  2. the layer (TreeItem) is deleted (GMFrame::OnDeleteLayer()) and with it the included button (the same as in the event)
  3. further event handling (in wx.lib.buttons.GenButton::OnLeftUp()) deals with a still living python object with a

"wrapped C/C++ object of type GenBitmapButton has been deleted"

I couldn't find a quick fix for this, but I'll try to come up with a solution. Still, if someone more experienced is up to the challenge to address this I'd be more than happy.

comment:11 by annakrat, 5 years ago

Thanks for the detailed analysis. I can't test but this might work:

diff --git a/gui/wxpython/lmgr/layertree.py b/gui/wxpython/lmgr/layertree.py
index 52c20dcc0..b2b39c613 100644
--- a/gui/wxpython/lmgr/layertree.py
+++ b/gui/wxpython/lmgr/layertree.py
@@ -421,7 +421,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             # select the layer in the same way as right click
             if not self.IsSelected(layer):
                 self.DoSelectItem(layer, True, False)
-            self.OnLayerContextMenu(event)
+            wx.CallAfter(self.OnLayerContextMenu, event)

comment:12 by neteler, 5 years ago

Milestone: 7.4.57.8.3
Version: 7.4.0git-releasebranch78

in reply to:  11 comment:13 by nila, 5 years ago

Replying to annakrat:

Thanks for the detailed analysis. I can't test but this might work:

diff --git a/gui/wxpython/lmgr/layertree.py b/gui/wxpython/lmgr/layertree.py
index 52c20dcc0..b2b39c613 100644
--- a/gui/wxpython/lmgr/layertree.py
+++ b/gui/wxpython/lmgr/layertree.py
@@ -421,7 +421,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             # select the layer in the same way as right click
             if not self.IsSelected(layer):
                 self.DoSelectItem(layer, True, False)
-            self.OnLayerContextMenu(event)
+            wx.CallAfter(self.OnLayerContextMenu, event)

Brilliant, it works fine, thanks!

Will you put up a PR?

comment:15 by annakrat, 5 years ago

Resolution: fixed
Status: newclosed

Merged to master and 78.

Note: See TracTickets for help on using tickets.