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

Offline wxLearner

  • Multiple posting newcomer
  • *
  • Posts: 71
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: Text
  1. void CodeSnippets::OnRelease(bool appShutDown)
  2. // ----------------------------------------------------------------------------
  3. {
  4.     if (not GetSnippetsWindow()) return;
  5.  
  6.     // Don't close down if file checking is active
  7.     while ( m_nOnActivateBusy )
  8.     {   wxMilliSleep(10) ; wxYield();
  9.     }
  10.  
  11.     CodeBlocksDockEvent evt(cbEVT_REMOVE_DOCK_WINDOW);
  12.     evt.pWindow = GetSnippetsWindow();
  13.     Manager::Get()->GetAppWindow()->ProcessEvent(evt);
  14.  
  15.     GetSnippetsWindow()->Destroy();
  16.     SetSnippetsWindow(0);
  17. }
to
Code: [Select]
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: 2173
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.