Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: frithjofh on March 05, 2019, 01:25:17 pm

Title: ReopenEditor plugin issues
Post by: frithjofh on March 05, 2019, 01:25:17 pm
Hi everybody,

encountered some problems with the ReopenEditor plugin. Found two issues:

Enabled it in plugins manager and it appeared in logs & others by default. After opening and closing files nothing appears in the output window of the plugin. Can anybody confirm this?

Choosing the option "Closed files list should be ... a dockable window" in the plugins settings dialog, c::b crashes immediately. Crash report attached. Can anybody confirm this?

My machine and setup: x86_64 Opensuse Linux. wxWidgets 3.0, c::b build from svn 11575.

Regards

frithjofh
Title: Re: ReopenEditor plugin issues
Post by: Miguel Gimenez on March 05, 2019, 01:53:03 pm
The crash is the same problem found in the ThreadSearch plugin (use after free), see ticket 777 and the forum

http://forums.codeblocks.org/index.php/topic,23061.0.html (http://forums.codeblocks.org/index.php/topic,23061.0.html)

In ReopenEditor::ShowList() the following line detachs and deletes m_pListLog:

Code: [Select]
    CodeBlocksLogEvent evt1(cbEVT_REMOVE_LOG_WINDOW, m_pListLog);
    Manager::Get()->ProcessEvent(evt1);

but inmediately after the code uses the deleted window again:

Code: [Select]
    if(m_IsManaged)
    {
        CodeBlocksLogEvent evt3(cbEVT_ADD_LOG_WINDOW, m_pListLog, _("Closed files list"),
                                &m_LogIcon);
        Manager::Get()->ProcessEvent(evt3);
        CodeBlocksLogEvent evt4(cbEVT_SWITCH_TO_LOG_WINDOW, m_pListLog);
        Manager::Get()->ProcessEvent(evt4);
    }
    else
    {
        m_pListLog->Reparent(Manager::Get()->GetAppFrame());
        m_pListLog->SetSize(wxSize(800,94));
        m_pListLog->SetInitialSize(wxSize(800,94));

        CodeBlocksDockEvent evt(cbEVT_ADD_DOCK_WINDOW);
        evt.name = _T("ReopenEditorListPane");
        evt.title = _("Closed file list");
        evt.pWindow = m_pListLog;
        evt.dockSide = CodeBlocksDockEvent::dsBottom;
        evt.shown = true;
        evt.hideable = true;
        evt.desiredSize.Set(800, 94);
        evt.floatingSize.Set(800, 94);
        evt.minimumSize.Set(350, 94);
        Manager::Get()->ProcessEvent(evt);
    }

I created a patch for ThreadSearch that should work here.

EDIT: the closed file list works OK for me.
Title: Re: ReopenEditor plugin issues
Post by: Miguel Gimenez on March 05, 2019, 07:34:31 pm
This simple patch fixes the crash (needs also the patch in ticket 777).
Title: Re: ReopenEditor plugin issues
Post by: Miguel Gimenez on March 07, 2019, 10:06:04 am
Created ticket 807

https://sourceforge.net/p/codeblocks/tickets/807 (https://sourceforge.net/p/codeblocks/tickets/807)