File r895519.diff of Package kdepim4
Subject: korganizerfix crash when deleting categories with deep subcategories
From: wstephenson@suse.de
Bug: kde#153740
Patch-upstream: 895519
--- libkdepim/categoryeditdialog.h (revision 895518)
+++ libkdepim/categoryeditdialog.h (revision 895519)
@@ -66,7 +66,7 @@ class KDEPIM_EXPORT CategoryEditDialog :
void fillList();
private:
- void deleteItem( QTreeWidgetItem *item );
+ void deleteItem( QTreeWidgetItem *item, QList<QTreeWidgetItem *> &to_remove );
KPimPrefs *mPrefs;
Ui::CategoryEditDialog_base *mWidgets;
};
--- libkdepim/categoryeditdialog.cpp (revision 895518)
+++ libkdepim/categoryeditdialog.cpp (revision 895519)
@@ -24,7 +24,6 @@
#include "categoryeditdialog.h"
#include "ui_categoryeditdialog_base.h"
#include "categoryhierarchyreader.h"
-#include "autochecktreewidget.h"
#include "kpimprefs.h"
#include <KLocale>
@@ -148,7 +147,7 @@ void CategoryEditDialog::remove()
{
QList<QTreeWidgetItem*> to_remove = mWidgets->mCategories->selectedItems();
while ( !to_remove.isEmpty() ) {
- deleteItem( to_remove.takeFirst() );
+ deleteItem( to_remove.takeFirst(), to_remove );
}
mWidgets->mButtonRemove->setEnabled( mWidgets->mCategories->topLevelItemCount() > 0 );
@@ -158,14 +157,16 @@ void CategoryEditDialog::remove()
}
}
-void CategoryEditDialog::deleteItem( QTreeWidgetItem *item )
+void CategoryEditDialog::deleteItem( QTreeWidgetItem *item, QList<QTreeWidgetItem *> &to_remove )
{
if ( !item ) {
return;
}
for ( int i = item->childCount() - 1; i >= 0; i-- ) {
- deleteItem( item->child( i ) );
+ QTreeWidgetItem *child = item->child( i );
+ to_remove.removeAll( child );
+ deleteItem( child, to_remove );
}
delete item;
}
Index: libkdepim/categoryeditdialog.h
===================================================================
Index: libkdepim/categoryeditdialog.cpp
===================================================================