News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

CB SDK event handler question

Started by ollydbg, June 20, 2012, 06:01:01 AM

Previous topic - Next topic

ollydbg

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.

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);
}


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.