Author Topic: CB SDK event handler question  (Read 6417 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
CB SDK event handler question
« on: June 20, 2012, 06:01:01 am »
See: Code::Blocks SDK events - CodeBlocks
and the change of rev 4234. I see that currently the "only" way to handle/register/subscribe a plugin's event handler is using Manager::RegisterEventSink method.

So, the traditionally Macro based (like EVT_EDITOR_CLOSE ) is useless, right?

Review the commit rev 4234, I see that the old Macro based way just plugin chains append the main app window. :)

Code in rev 4233.
Code
void PluginManager::NotifyPlugins(CodeBlocksEvent& event)
{
    if (Manager::IsAppShuttingDown())
        return;

    /* Things are simpler than before.
     * Just ask the last active plugin to process this event.
     * Because plugins are linked to the main app's event handler,
     * the event will travel up the chain normally.
     */
    if (s_LastKnownActivePlugin)
        s_LastKnownActivePlugin->ProcessEvent(event);
    else
        Manager::Get()->GetAppWindow()->ProcessEvent(event);
//    // notify plugins
//    for (unsigned int i = 0; i < m_Plugins.GetCount(); ++i)
//    {
//        cbPlugin* plug = m_Plugins[i]->plugin;
//        if (plug && plug->IsAttached())
//            plug->ProcessEvent(event);
//    }
//
//    // notify the app too
//    Manager::Get()->GetAppWindow()->ProcessEvent(event);
}

« Last Edit: June 20, 2012, 06:58:18 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.