From 1a2a6c152dbb467f31bd809098a19f4c90c6d48f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Jun 2009 09:57:38 +0200 Subject: Fix crash in widget box when using load mode "LoadCustomWidgetsOnly" When loading the widget box with load mode "LoadCustomWidgetsOnly", it will create an empty category. This will indirectly cause a resize event to be posted for the tree widget of the widget box, which in turn will cause adjustSubListSize() to be called for each category item in the tree widget. Since the category has not yet been populated, the assumption in adjustSubListSize() that cat_item->child(0) is non-null would cause a crash. The fix is to return immediately if the category is empty. Reviewed-by: Friedemann Kleint --- tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp index 99dfb9c..38e3501 100644 --- a/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -664,6 +664,9 @@ WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem *cat_item) { QTreeWidgetItem *embedItem = cat_item->child(0); + if (embedItem == 0) + return; + WidgetBoxCategoryListView *list_widget = static_cast(itemWidget(embedItem, 0)); list_widget->setFixedWidth(header()->width()); list_widget->doItemsLayout(); -- cgit v0.12