From 0b3bfd931f260f8ee1aa20d0245c44f1eb46fffb Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 11 Dec 2012 00:51:16 +0000 Subject: Fixed crash during model changes. --- libqmenumodel/src/qmenumodel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libqmenumodel/src') 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 -- cgit v1.2.3