Summary: | Crash on clicking 'Create File' in dropdown menu in 'Projects' dock | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Alexey Chernov <4ernov> |
Component: | general | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | aleixpol, aspotashev |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | 4.2.0 | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdevplatform/0abcf15da28e21b033d66daf2ea0e6a4ce413601 | Version Fixed In: | |
Sentry Crash Report: |
Description
Alexey Chernov
2011-01-06 14:04:40 UTC
Looks like an item got deleted for which the context menu was requested... There is simply no safeguard against it, we really need smart pointers in the project model... *sigh* thanks for the report, I wonder whether there is something we can do in the short term to workaround this, like saving urls + project + itemtype or something like that in the project manager plugin context menu items... Are you sure that's the reason? In my system I have an if() in that line... I think that the case that the folder for which you are trying to add a file has been removed is unlikely. We can do better in that code without rewriting the project model. When I checked I had something like if(item->...) in the loc that crashed, with the item coming out of the d->ctxMenuItems container or how that was called. Really, it is an invalid item. The only way to prevent against this (hopefully very rare) case where items get deleted while the context menu is shown, is to a) store PDOs (KUrl and maybe more to speedup the lookup process), or b) rewrite the project api to use smart pointers I'd like to have b eventually, but a would do for a quick'n'dirty workaround. Btw. Andreas confirmed this. In this case it looks like a bug in the project manager, apparently the folder is not removed. But yes, some refactoring is needed. I'd like to note, though, that a typical shared pointer is not valid here, because the best case in that regard is to report that we're trying to add a file to a wrong folder (instead of crashing of course), so storing that information doesn't make much sense. The quick fix here is to store the url and lookup the item, anyway. Actually the addFile method shouldn't be in the API anyway, because all the project managers end up by watching the filesystem so the way to add a file to a project is to actually create the file. Git commit 0abcf15da28e21b033d66daf2ea0e6a4ce413601 by Aleix Pol. Committed on 08/10/2013 at 00:48. Pushed by apol into branch 'master'. Don't store pointers ProjectBaseItem in classes They could be deleted before used. Store the model index instead. M +28 -15 plugins/projectmanagerview/projectmanagerviewplugin.cpp http://commits.kde.org/kdevplatform/0abcf15da28e21b033d66daf2ea0e6a4ce413601 |