Crash after requesting context menu (after reopening the project)

Manuel Breugelmans mbr.nxi at
Wed Jul 30 23:59:24 UTC 2008

On Wednesday 30 July 2008 00:43:17 Andreas Pakulat wrote:
> Hmmm... I can't see how this could happen. Granted the project pointer
> itself isn't deleted until the event loop runs again after closing it,
> but the project items are being deleted properly. So the project tree
> has to have the new items and their project() pointer needs to be
> "proper".
> You should be able to debug this by simply printing out the pointer of
> the project in projectcontroller::closeProject() before its deleted and
> then also in veritas coverageplugin before the crash line. Those two
> pointers should be different. If they are, there must be a problem
> elsehwere.

I've given this a long hard look and spotted the culprit. Not dvcs nor veritas 
but some obscure plugin loading code in projectcontroller [ the person that 
introduced this now owes +1 beer to Evgeniy & me :) ]

I deduced this with the following minimal test cases:
*/ start kdev4 >> load project >> reopen project [no close, just recent-
>project] >> context menu >> crash
*/  start kdev4 >> load project >> close project >> load project >> context 
menu >> no crash
*/ start kdev4 >> load cmake project >> load other cmake project >> reload 
cmake project >> context on reloaded >> no crash
*/ start kdev4 >> load cmake project >> load make project >> reload cmake 
project >> context menu reloaded >> crash

On a reopen project ProjectController unloads the KDevCmakeBuilder plugin (IF 
no other open projects use it) then immediatly loads it again, which results 
in that segfault.

Attached is a patch which:
1. Fixes this bug, by not unloading plugins when reloading a project which is 
redundant anyway
2. Refactor the ProjectController->closeProject() member as this had started 
to rot
3. Remove faulty signals from ProjectController, which are also present in 
4. Add a unit test for ProjectController

@Powerfox: could you apply and confirm that this indeed gets rid of the problem 
+ run that test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdev_projectcontroller.patch
Type: text/x-patch
Size: 16507 bytes
Desc: not available
URL: <>

More information about the KDevelop-devel mailing list