[Bug 63556] KATE: Crash when right clicking with large selection in H file

Jens Dagerbo jens.dagerbo at swipnet.se
Tue Sep 2 08:34:04 UTC 2003

Executive summary: CppSupport assumes that if a .cpp file exists in the 
CodeModel and there is a corresponding .h file (or vice versa, probably), 
the .h file must be in the CodeModel too. This isn't true, and the result is 
a crash.

> http://bugs.kde.org/show_bug.cgi?id=63556

OK... I'm not even completely sure that the crash I think I've identified is 
the crash reported, but it is similar. The reason I'm not simply fixing it is 
that I can't really say I understand the code.. :) Here goes...

To reproduce: 
Start Gideon, load a project, open a .cpp that is NOT part of the project (not 
part of the CodeModel). 

Rightclick the file in the editor -> CRASH

It appears that any file open in Gideon becomes part of the codemodel (even 
simple text files, I tried it with an INSTALL file). This doesn't go well 
with the piece of code that attempts to find the declarations matching the 
definitions of .h / .cpp files in CppSupportPart::contextMenu()

Simply changing parts/cppsupportpart/cppsupportpart.cpp: 464 (version 1.217) 

if ( !candidate.isEmpty() )


if ( !candidate.isEmpty() && codeModel()->hasFile( canidate ) )

stops it from crashing here.

However, and the reason I'm not simply committing, is this correct, or does it 
simply cover the real problem? In the time I spent looking at this I really 
didn't understand enough about the refcounted design to have any idea if it 
is correct or not. Debugging I ended up with confusing results like 
uninitialized QStrings if the process was allowed through CodeModel::
fileByName() without finding the file, something I wouldn't expect to happen. 
If the alternate return ( simply "FileDom()" ) is in any way "legal", it 
shouldn't blow up. Or? :)


More information about the KDevelop-devel mailing list