Author Topic: Missing event.Skip()'s in CB app.cpp  (Read 4214 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2839
Missing event.Skip()'s in CB app.cpp
« on: March 22, 2007, 04:49:03 pm »
CB app.cpp OnAppActivate() is completely missing its event.Skip()'s

This is causing the plugins to be unable to use the event to check if their database files have been modified externally. Especially CodeSnippets.



I believe the code should look like:

Code
void CodeBlocksApp::OnAppActivate(wxActivateEvent& event)
{
if (s_Loading)
{   event.Skip();
return; // still loading; we can't possibly be interested for this event ;)
}
if (!event.GetActive())
{   event.Skip();
return;
}
    if (!Manager::Get())
    {   event.Skip();
        return;
    }

    if (Manager::Get()->GetEditorManager() && Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/check_modified_files"), true))
    {
    // for some reason a mouse up event doen's make it into scintilla (scintilla bug)
    // therefor the workaournd is not to directly call the editorManager, but
    // take a detour through an event
    // the bug is when the file has been offered to reload, no matter what answer you
    // give the mouse is in a selecting mode, adding/removing things to it's selection as you
    // move it around
    // so : idEditorManagerCheckFiles, EditorManager::OnCheckForModifiedFiles just exist for this workaround
        wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, idEditorManagerCheckFiles);
        wxPostEvent(Manager::Get()->GetEditorManager(), evt);
//        Manager::Get()->GetEditorManager()->CheckForExternallyModifiedFiles();
        Manager::Get()->GetProjectManager()->CheckForExternallyModifiedProjects();
    }
    cbEditor* ed = Manager::Get()->GetEditorManager()
                    ? Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor()
                    : 0;
if (ed)
{
// hack for linux: without it, the editor loses the caret every second activate o.O
Manager::Get()->GetEditorManager()->GetNotebook()->SetFocus();

ed->GetControl()->SetFocus();
}
event.Skip();
}



The Wxwidges manual states:
Quote
Remarks

A top-level window (a dialog or frame) receives an activate event when it is being activated or deactivated. This is indicated visually by the title bar changing colour, and a subwindow gaining the keyboard focus.

An application is activated or deactivated when one of its frames becomes activated, or a frame becomes inactivated resulting in all application frames being inactive. (Windows only)

Please note that usually you should call event.Skip() in your handlers for these events as not doing so can result in strange effects.


« Last Edit: March 22, 2007, 04:51:03 pm by Pecan »