fix crash on navigation crash, when clicking on '__1' container of clang's libc++ std::__1::string
ClosedPublic

Authored by amccann on Nov 21 2015, 12:53 AM.

Details

Summary

On OSX, with XCode's clang, the code browser would show "std::string" being a part of container "__1" (implementation detail of libc++ I believe)

Clicking this "__1" crashed, repeatably.

This fix simply checks if the value is null, and does not try to access it.

Diff Detail

Repository
R33 KDevPlatform
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
amccann updated this revision to Diff 1331.Nov 21 2015, 12:53 AM
amccann retitled this revision from to fix crash on navigation crash, when clicking on '__1' container of clang's libc++ std::__1::string.
amccann updated this object.
amccann edited the test plan for this revision. (Show Details)
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptNov 21 2015, 12:53 AM
amccann updated this object.Nov 21 2015, 12:59 AM
amccann added a reviewer: KDevelop.
amccann added a project: KDevelop.
amccann added inline comments.
language/duchain/navigation/abstractnavigationcontext.cpp
234–236

Please advise if the "else" return value is appropriate.

mwolff accepted this revision.Nov 22 2015, 6:54 PM
mwolff edited edge metadata.

lgtm as a hotfix

language/duchain/navigation/abstractnavigationcontext.cpp
227–228

could we maybe fix this for real? the code is evil indeed... maybe something for the future though

234–236

phew - good question. is the behavior in the case where it crashed before OK now? what happens when you return {};?

This revision is now accepted and ready to land.Nov 22 2015, 6:54 PM
amccann added inline comments.Nov 23 2015, 8:48 PM
language/duchain/navigation/abstractnavigationcontext.cpp
234–236
return {};

has the same effect as

return NavigationContextPointer(this);

That said, the original author always used the latter in other contexts in the calling function, so I am sticking with the same pattern.

As for the behavior, it simply doesn't crash now. Clicking the "__1" has no effect now.

This revision was automatically updated to reflect the committed changes.