Author Topic: CodeSnippets save-dock-position issue and possible solution  (Read 5125 times)

wxLearner

  • Guest
CodeSnippets save-dock-position issue and possible solution
« 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?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: CodeSnippets save-dock-position issue and possible solution
« Reply #1 on: April 24, 2007, 02:02:25 pm »
Thank you. Will correct on next commit.