From: Frederik Gladhorn Date: Mon, 19 Jan 2009 00:16:17 +0000 (+0000) Subject: fix crash when deleting document - removal from word type would try to access already... X-Git-Tag: v4.2.85~7 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=5841472d36db9e745d6232e3d3fbf088040d5e3a;p=libqmvoc.git fix crash when deleting document - removal from word type would try to access already deleted translations again Thanks Albert!!!!! svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=913263 --- diff --git a/keduvocdocument/keduvocexpression.cpp b/keduvocdocument/keduvocexpression.cpp index 10e4ee5..63d5ac3 100644 --- a/keduvocdocument/keduvocexpression.cpp +++ b/keduvocdocument/keduvocexpression.cpp @@ -45,7 +45,10 @@ public: KEduVocExpression::KEduVocExpressionPrivate::~KEduVocExpressionPrivate() { - qDeleteAll(m_translations); + QMap translations = m_translations; + // empty the translations map, otherwise removal from word type will try to access them again when they don't exist any more + m_translations.clear(); + qDeleteAll(translations); } KEduVocExpression::KEduVocExpressionPrivate::KEduVocExpressionPrivate(const KEduVocExpressionPrivate & other) diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp index e5e32a8..65b0638 100644 --- a/keduvocdocument/keduvocwordtype.cpp +++ b/keduvocdocument/keduvocwordtype.cpp @@ -91,7 +91,6 @@ void KEduVocWordType::removeTranslation(KEduVocTranslation* translation) } } - // TODO translation(i)'s d pointer can be null. How should we fix this? // remove from cache bool found = false; foreach(int i, translation->entry()->translationIndices()) {