I can't reproduce it reliably, seems to happen randomly opening the same project... no idea what it is now. But no crashes with CC disabled, again.
Well, now that the workerthread code is gone, at least it'll be easier for us to identify the culprit. After some deductions, the only possibility left is that it's my fault, and I have understood why :oops:. I wasn't still not sure why, until the crash was reproduced without Thomas' code.
K, here goes...
In my latest change to Code Completion, to fix the class browser not being updated, i moved the code that parses the active projects, from a wxTimerEvent handler, to the OnWorkspaceLoaded event handler. After looking at the app.cpp code a few minutes ago, I noticed that the parsing starts BEFORE it should, making these random crashes appear. Since it's multithreaded, the error only gets triggered either on very fast machines, or on very slow machines.
(The problem is that these 3 changes took place in the same build - from 4165 to 4169: 1) Thomas' workerthread change, 2) dmoore's memleak fix, and 3) My apparently-harm change to the parsing)
Anyway...
bool CodeBlocksApp::OnInit()
{
...
MainFrame* frame = 0; frame = InitFrame();
m_Frame = frame;
...
Manager::Get()->GetMessageManager()->DebugLog(_T("Initializing plugins..."));
CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
Manager::Get()->ProcessEvent(event);
Manager::ProcessPendingEvents();
splash.Hide();
}
The problem is that m_Frame isn't set in the middle of InitFrame, and guess what happens in there:
MainFrame* CodeBlocksApp::InitFrame()
{
...
Manager::Get()->GetProjectManager()->LoadWorkspace();
...
}
And in LoadWorkspace...
CodeBlocksEvent event(cbEVT_WORKSPACE_LOADED);
Manager::Get()->GetPluginManager()->NotifyPlugins(event);
So, Thomas, you were both right and wrong: The error was triggered by Code Completion because it's the ONLY plugin yet that uses the new EVT_WORKSPACE_LOADED; but the fault lies within my changes to ProjectManager, because I didn't take into account that the app hadn't been initialized yet in all workspace loads.
And *THIS* is why it happened *ONLY* if you had a workspace open beforehand.
I'll fix ProjectManager so that it only sends the event after the main frame has been initialized. But please don't re-commit your backgroundthread change until we have tested my change... just to be on the safe side :mrgreen:
Edit: I modified the code and am compiling, but I have to go to the job now
I'll commit in around 10 hours, sorry...