From d9871d1a3b2250007a053830b97c4d00ef3982a1 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 17 May 2008 11:44:10 +0000 Subject: [PATCH] Fix: delete of entries that had a wort type associated would kill the whole show. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=808709 --- keduvocdocument/keduvocexpression.cpp | 5 +---- keduvocdocument/keduvocwordtype.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/keduvocdocument/keduvocexpression.cpp b/keduvocdocument/keduvocexpression.cpp index 466c0b9..e606b53 100644 --- a/keduvocdocument/keduvocexpression.cpp +++ b/keduvocdocument/keduvocexpression.cpp @@ -93,10 +93,8 @@ KEduVocExpression::KEduVocExpression( const QStringList & translations) KEduVocExpression::KEduVocExpression(const KEduVocExpression & other) : d(new KEduVocExpressionPrivate(*other.d)) { - kDebug() << "Expression copy constructor"; foreach (int key, other.d->m_translations.keys()) { d->m_translations[key] = new KEduVocTranslation(*other.d->m_translations.value(key)); - kDebug() << "copy translation: " << other.d->m_translations.value(key)->text(); d->m_translations[key]->setEntry(this); } } @@ -118,7 +116,6 @@ KEduVocExpression::~KEduVocExpression() delete d; } - void KEduVocExpression::removeTranslation( int index ) { delete d->m_translations.take(index); @@ -183,7 +180,7 @@ bool KEduVocExpression::operator== ( const KEduVocExpression &expression ) const KEduVocTranslation* KEduVocExpression::translation( int index ) { - if(d->m_translations.contains(index)) { + if(translationIndices().contains(index)) { return d->m_translations[index]; } d->m_translations[index] = new KEduVocTranslation(this); diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp index da45c6d..e84241c 100644 --- a/keduvocdocument/keduvocwordtype.cpp +++ b/keduvocdocument/keduvocwordtype.cpp @@ -83,7 +83,17 @@ void KEduVocWordType::addTranslation(KEduVocTranslation* translation) void KEduVocWordType::removeTranslation(KEduVocTranslation* translation) { - d->m_translations.removeAt( d->m_translations.indexOf(translation)); +kDebug() << "Remove Translation from wt"; + + d->m_translations.removeAt( d->m_translations.indexOf(translation) ); + + // no lesson found - this entry is being deleted. remove all its siblings. + if (!translation->entry()->lesson()) { + int index = d->m_expressions.indexOf(translation->entry()); + if (index != -1) { + d->m_expressions.removeAt(index); + } + } // remove from cache bool found = false; -- 2.47.3