Opened 2 years ago
Closed 10 months ago
#3607 closed defect (fixed)
Removing map layer crashes wxGUI
Reported by: | cmbarton | Owned by: | |
---|---|---|---|
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)
Change History (16)
comment:1 Changed 2 years ago by
Milestone: | → 7.4.2 |
---|
comment:2 Changed 2 years ago by
comment:3 Changed 2 years ago by
Every time, but only if removed in this way. All other remove methods work fine.
comment:7 Changed 11 months ago by
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 11 months ago by
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 11 months ago by
Yes, this only crashes when removing layer from button-menu.
But not from contextual menu (right click), where it works as expected.
comment:10 Changed 10 months ago by
I managed to find the cause of this bug (see attachment above). In short:
- clicking the button triggers an event with the
GenBitmapButton
embedded - the layer (
TreeItem
) is deleted (GMFrame::OnDeleteLayer()
) and with it the included button (the same as in the event) - 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 follow-up: 13 Changed 10 months ago by
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 10 months ago by
Milestone: | 7.4.5 → 7.8.3 |
---|---|
Version: | 7.4.0 → git-releasebranch78 |
comment:13 Changed 10 months ago by
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 10 months ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Merged to master and 78.
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?