Kirix Support Forums

NULL Pointer access due to order dependency

Please post any wxAUI patches or modifications you've created here. Thanks!

NULL Pointer access due to order dependency

Postby epage on Fri Jul 28, 2006 7:57 pm

Sometimes wxFloatingPane is Destroy'ed when docking and it will still recieve a OnMoveEvent. This will lead to
Code: Select all
void wxFrameManager::OnFloatingPaneMoving(wxWindow* wnd)

Being called, which executes this line
Code: Select all
wxPoint frame_pos = pane.frame->GetPosition();

And the pane.frame has already been set to NULL

So I added:
Code: Select all
    virtual bool Destroy ()
    {
        m_pane_window = NULL;
        return wxFloatingPaneBaseClass::Destroy();
    }

to wxFloatingPane

Then on the events I return early if it is NULL instead of calling m_owner_mgr->OnFloatingPaneMoveStart(m_pane_window);

Code: Select all
    void OnMoveStart()
    {
        if (m_pane_window == NULL)
            return;
        // notify the owner manager that the pane has started to move
        m_owner_mgr->OnFloatingPaneMoveStart(m_pane_window);
    }

    void OnMoving(const wxRect& window_rect)
    {
        if (m_pane_window == NULL)
            return;
        // notify the owner manager that the pane is moving
        m_owner_mgr->OnFloatingPaneMoving(m_pane_window);
    }

    void OnMoveFinished()
    {
        if (m_pane_window == NULL)
            return;
        // notify the owner manager that the pane has finished moving
        m_owner_mgr->OnFloatingPaneMoved(m_pane_window);
    }

    void OnActivate(wxActivateEvent& event)
    {
        if (m_pane_window == NULL)
            return;
        if (event.GetActive())
        {
            m_owner_mgr->OnFloatingPaneActivated(m_pane_window);
        }
    }
...
    void OnSize(wxSizeEvent& event)
    {
        if (m_pane_window == NULL)
            return;
        m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize());
    }
   
    void OnClose(wxCloseEvent& event)
    {
        if (m_pane_window == NULL)
        {
            Destroy();
            return;
        }
        m_owner_mgr->OnFloatingPaneClosed(m_pane_window);
        Destroy();
    }


The protection could be put in several places, It could be put higher up, like OnMouseEvent, but then it loses its meaning and could accidently removed, or called around it by a new function. It could be moved lower, Pre-Condition checks that fail silently but I wanted my changes isolated so I could keep track of them better.

Sorry no patches, its simple and I am not too familiar with patch programs (I haven't had the opportunity to contribute back too much in the past).
epage
Registered User
 
Posts: 10
Joined: Thu Jul 13, 2006 2:16 pm

Postby Ben on Tue Oct 31, 2006 3:00 am

This appears to be the same bug that has bothered everybody. It's been fixed in the latest CVS. See the other recent posts for more info.

Thanks,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Return to wxAUI Patches & Modifications