aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-11 00:51:16 +0000
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-11 00:51:16 +0000
commit0b3bfd931f260f8ee1aa20d0245c44f1eb46fffb (patch)
tree4e0bf8330b19e3e5695e32f7f4240bfdfa07be67 /libqmenumodel/src
parent5c88419b11b88640305f0b55b3ae453a68934233 (diff)
downloadqmenumodel-0b3bfd931f260f8ee1aa20d0245c44f1eb46fffb.tar.gz
qmenumodel-0b3bfd931f260f8ee1aa20d0245c44f1eb46fffb.tar.bz2
qmenumodel-0b3bfd931f260f8ee1aa20d0245c44f1eb46fffb.zip
Fixed crash during model changes.
Diffstat (limited to 'libqmenumodel/src')
-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