agw.aui segfault on Ubuntu when dragging a pane out of a tab container

Hi,

On Ubuntu, wxPython 2.8.10.1, both with the agw.aui included in
wxPython 2.8.10.1 as well as with the latest version from svn I can
trigger a segfault as follows: start the AUI.py demo and drag the left
tree pane onto the bottom text pane, causing a tab container to occur
with both panes in it. Drag one of the tabs out: boom! segfault.
Inserting some print statements shows that line 6450 is triggering the
segfault:

    def OnTabBeginDrag(self, event):
        ...
        if self._masterManager:
            self._masterManager.OnTabBeginDrag(event)

        else:
            paneInfo = self.PaneFromTabEvent(event)

            if paneInfo.IsOk():

                # It's one of ours!
                self._action = actionDragFloatingPane
                mouse = wx.GetMousePosition()

                # set initial float position - may have to think about this
                # offset a bit more later ...
                self._action_offset = wx.Point(20, 10)
                paneInfo.floating_pos = mouse - self._action_offset
                paneInfo.dock_pos = AUI_DOCK_NONE
                paneInfo.notebook_id = -1

                tab = event.GetEventObject()

                # float the window
                if paneInfo.IsMaximized():
                    self.RestorePane(paneInfo)
                paneInfo.Float()
                self.Update()

                self._action_window = paneInfo.window

                if wx.Window.GetCapture() == tab: # <------ segfault
                    tab.ReleaseMouse()

When I slightly change line 6450 code to read:

    if tab.HasCapture():
        tab.ReleaseMouse()

I receive this traceback:

Traceback (most recent call last):
  File "/home/frank/wxPythonDemo/wxPython-2.8.10.1/demo/agw/aui/framemanager.py",
line 6422, in OnTabBeginDrag
    self._masterManager.OnTabBeginDrag(event)
  File "/home/frank/wxPythonDemo/wxPython-2.8.10.1/demo/agw/aui/framemanager.py",
line 6450, in OnTabBeginDrag
    if tab.HasCapture():
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 14564, in __getattr__
    raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the AuiTabCtrl object has
been deleted, attribute access no longer allowed.

So apparently the tab has already been destroyed before this code has
a chance to release the tab's mouse capture. I'm not sure how to fix
that.

Cheers, Frank

Hi Frank,

2009/10/10 Frank Niessink:

Hi,

On Ubuntu, wxPython 2.8.10.1, both with the agw.aui included in
wxPython 2.8.10.1 as well as with the latest version from svn I can
trigger a segfault as follows: start the AUI.py demo and drag the left
tree pane onto the bottom text pane, causing a tab container to occur
with both panes in it. Drag one of the tabs out: boom! segfault.
Inserting some print statements shows that line 6450 is triggering the
segfault:

def OnTabBeginDrag(self, event):
...
if self._masterManager:
self._masterManager.OnTabBeginDrag(event)

   else:
       paneInfo = self\.PaneFromTabEvent\(event\)

       if paneInfo\.IsOk\(\):

           \# It&#39;s one of ours\!
           self\.\_action = actionDragFloatingPane
           mouse = wx\.GetMousePosition\(\)

           \# set initial float position \- may have to think about this
           \# offset a bit more later \.\.\.
           self\.\_action\_offset = wx\.Point\(20, 10\)
           paneInfo\.floating\_pos = mouse \- self\.\_action\_offset
           paneInfo\.dock\_pos = AUI\_DOCK\_NONE
           paneInfo\.notebook\_id = \-1

           tab = event\.GetEventObject\(\)

           \# float the window
           if paneInfo\.IsMaximized\(\):
               self\.RestorePane\(paneInfo\)
           paneInfo\.Float\(\)
           self\.Update\(\)

           self\.\_action\_window = paneInfo\.window

           if wx\.Window\.GetCapture\(\) == tab: \# &lt;\-\-\-\-\-\- segfault
               tab\.ReleaseMouse\(\)

When I slightly change line 6450 code to read:

if tab.HasCapture():
tab.ReleaseMouse()

I receive this traceback:

Traceback (most recent call last):
File "/home/frank/wxPythonDemo/wxPython-2.8.10.1/demo/agw/aui/framemanager.py",
line 6422, in OnTabBeginDrag
self._masterManager.OnTabBeginDrag(event)
File "/home/frank/wxPythonDemo/wxPython-2.8.10.1/demo/agw/aui/framemanager.py",
line 6450, in OnTabBeginDrag
if tab.HasCapture():
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 14564, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the AuiTabCtrl object has
been deleted, attribute access no longer allowed.

So apparently the tab has already been destroyed before this code has
a chance to release the tab's mouse capture. I'm not sure how to fix
that.

I can't really test on GTK, but I have committed a kind of a blind fix
in SVN. Could you please see if it works? Otherwise I'll re-install my
VM and I'll try again.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Now the segfault occurs on the next line:

                 self._frame.CaptureMouse()

If I uncomment that line as well, a new window with the dragged out
pane shows for a brief moment and then a segfault occurs.

I think the strategy to fix this should be to release the mouse
capture of the tab before it gets destroyed. I'll see what I can do.

Cheers, Frank

···

2009/10/11 Andrea Gavana <andrea.gavana@gmail.com>:

2009/10/10 Frank Niessink:

So apparently the tab has already been destroyed before this code has
a chance to release the tab's mouse capture. I'm not sure how to fix
that.

I can't really test on GTK, but I have committed a kind of a blind fix
in SVN. Could you please see if it works? Otherwise I'll re-install my
VM and I'll try again.

Indeed, releasing the tab's mouse capture before floating the pane
solves the issue for me. See attached patch.

Cheers, Frank

patch.txt (730 Bytes)

···

2009/10/11 Frank Niessink <frank@niessink.com>:

I think the strategy to fix this should be to release the mouse
capture of the tab before it gets destroyed. I'll see what I can do.

Hi Frank,

···

2009/10/11 Frank Niessink <frank@niessink.com>:

2009/10/11 Frank Niessink <frank@niessink.com>:

I think the strategy to fix this should be to release the mouse
capture of the tab before it gets destroyed. I'll see what I can do.

Indeed, releasing the tab's mouse capture before floating the pane
solves the issue for me. See attached patch.

Patch applied in SVN, thank you!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/