summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/qmenu.cpp')
-rw-r--r--src/gui/widgets/qmenu.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 404d46e..9e190b7 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -1398,12 +1398,14 @@ QMenu::QMenu(QMenuPrivate &dd, QWidget *parent)
QMenu::~QMenu()
{
Q_D(QMenu);
- QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
- for (; it != d->widgetItems.end(); ++it) {
- if (QWidget *widget = it.value()) {
- QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
- action->releaseWidget(widget);
- *it = 0;
+ if (!d->widgetItems.isEmpty()) { // avoid detach on shared null hash
+ QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
+ for (; it != d->widgetItems.end(); ++it) {
+ if (QWidget *widget = it.value()) {
+ QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
+ action->releaseWidget(widget);
+ *it = 0;
+ }
}
}