Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: wxLearner on April 24, 2007, 10:16:52 am

Title: CodeSnippets save-dock-position issue and possible solution
Post by: wxLearner on April 24, 2007, 10:16:52 am
Hello,
the the codesnippets' dock-position gets forgotten after shutting down Code::Blocks. A possible solution is to modify the OnRelease method from
Code: codesnippets.cpp, line 160
void CodeSnippets::OnRelease(bool appShutDown)
// ----------------------------------------------------------------------------
{
    if (not GetSnippetsWindow()) return;

    // Don't close down if file checking is active
    while ( m_nOnActivateBusy )
    {   wxMilliSleep(10) ; wxYield();
    }

    CodeBlocksDockEvent evt(cbEVT_REMOVE_DOCK_WINDOW);
    evt.pWindow = GetSnippetsWindow();
    Manager::Get()->GetAppWindow()->ProcessEvent(evt);

    GetSnippetsWindow()->Destroy();
    SetSnippetsWindow(0);
}
to
Code
void CodeSnippets::OnRelease(bool appShutDown)
// ----------------------------------------------------------------------------
{
    if (not GetSnippetsWindow()) return;
   
    if(!appShutDown)//Don't remove the pane, if Code::Blocks shuts down
    {
        // Don't close down if file checking is active
        while ( m_nOnActivateBusy )
        {   wxMilliSleep(10) ; wxYield();
        }

        CodeBlocksDockEvent evt(cbEVT_REMOVE_DOCK_WINDOW);
        evt.pWindow = GetSnippetsWindow();
        Manager::Get()->GetAppWindow()->ProcessEvent(evt);

        GetSnippetsWindow()->Destroy();
        SetSnippetsWindow(0);
    }
}
I'm not familiar with wxAUI, so I don't know, if this will lead to a memory leak, but I don't think so, because a wxWidgets window normally deletes it's child controls/windows automatically while being destroyed, doesn't it?
Title: Re: CodeSnippets save-dock-position issue and possible solution
Post by: Pecan on April 24, 2007, 02:02:25 pm
Thank you. Will correct on next commit.