Skip to content
Snippets Groups Projects
Commit a9dae127 authored by Kevin Funk's avatar Kevin Funk
Browse files

Fix crash / odd behavior in project tree view

This patch fixes:
- Crash when trying to delete project target
- Removes pop-up that appeared when trying to delete
  a root item.

Removed the asserts because this function is actually ment to remove *items*,
hence the input is unfiltered and may not contain only files and
folders.

BUG: 321315
REVIEW: 11107
parent 1778a663
No related branches found
No related tags found
No related merge requests found
......@@ -501,18 +501,14 @@ void ProjectManagerViewPlugin::removeItems(const QList< ProjectBaseItem* >& item
}
//copy the list of selected items and sort it to guarantee parents will come before children
QMap< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> > filteredItems;
filteredItems[0] = items;
qSort(filteredItems[0].begin(), filteredItems[0].end(), ProjectBaseItem::urlLessThan);
QList<KDevelop::ProjectBaseItem*> sortedItems = items;
qSort(sortedItems.begin(), sortedItems.end(), ProjectBaseItem::urlLessThan);
KUrl lastFolder;
QMap< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> > filteredItems;
QStringList itemPaths;
foreach( KDevelop::ProjectBaseItem* item, filteredItems[0] )
foreach( KDevelop::ProjectBaseItem* item, sortedItems )
{
Q_ASSERT(item->folder() || item->file());
Q_ASSERT(!item->file() || !item->file()->parent()->target());
if (item->isProjectRoot()) {
continue;
} else if (item->folder() || item->file()) {
......@@ -523,8 +519,11 @@ void ProjectManagerViewPlugin::removeItems(const QList< ProjectBaseItem* >& item
lastFolder = item->url();
}
filteredItems[item->project()->projectFileManager()] << item;
itemPaths << item->url().path();
IProjectFileManager* manager = item->project()->projectFileManager();
if (manager) {
filteredItems[manager] << item;
itemPaths << item->url().path();
}
}
}
......@@ -547,8 +546,8 @@ void ProjectManagerViewPlugin::removeItems(const QList< ProjectBaseItem* >& item
QMap< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> >::iterator it;
for (it = filteredItems.begin(); it != filteredItems.end(); ++it)
{
if (it.key())
it.key()->removeFilesAndFolders(it.value());
Q_ASSERT(it.key());
it.key()->removeFilesAndFolders(it.value());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment