aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libqmenumodel/src/qmenumodel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 1326d77..9a2450c 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -133,7 +133,8 @@ void QMenuModel::clearModel()
}
Q_FOREACH(QMenuModel* child, *m_cache) {
- delete child;
+ child->setMenuModel(NULL);
+ child->deleteLater();
}
m_cache->clear();
}
@@ -295,7 +296,9 @@ void QMenuModel::onItemsChanged(GMenuModel *model,
// Remove invalidated menus from the cache
for (int i = position, iMax = position + removed; i < iMax; ++i) {
if (cache->contains(i)) {
- delete cache->take(i);
+ QMenuModel *model = cache->take(i);
+ model->setMenuModel(NULL);
+ model->deleteLater();
}
}
// Update the indexes of other cached menus to account for the removals