Opened 2 years ago

Closed 6 months 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 7 months ago.
backtrace log up to crash

Download all attachments as: .zip

Change History (16)

comment:1 Changed 2 years ago by cmbarton

Milestone: 7.4.2

comment:2 Changed 2 years ago by annakrat

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 Changed 2 years ago by cmbarton

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

comment:4 Changed 2 years ago by neteler

Milestone: 7.4.27.4.3

Ticket retargeted after milestone closed

comment:5 Changed 22 months ago by martinl

Milestone: 7.4.37.4.4

Bump milestone to 7.4.4

comment:6 Changed 21 months ago by neteler

Milestone: 7.4.47.4.5

Ticket retargeted after milestone closed

comment:7 Changed 7 months ago by nila

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 Changed 7 months ago by annakrat

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 Changed 7 months ago by nila

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

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

Changed 7 months ago by nila

backtrace log up to crash

comment:10 Changed 7 months ago by nila

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 Changed 6 months ago by 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)

comment:12 Changed 6 months ago by neteler

Milestone: 7.4.57.8.3
Version: 7.4.0git-releasebranch78

comment:13 in reply to:  11 Changed 6 months ago by nila

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 Changed 6 months ago by annakrat

Resolution: fixed
Status: newclosed

Merged to master and 78.

Note: See TracTickets for help on using tickets.