From: Frederik Gladhorn Date: Sun, 16 Dec 2007 00:47:19 +0000 (+0000) Subject: Add even more sanity: X-Git-Tag: v4.0.71~93^2~7 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=bcb3e062c3d75f4b6dce33bbe04ef2e6225cc144;p=libqmvoc.git Add even more sanity: - When deleting an entry, let's remove it from the word type lesson. - Only delete an entry when deleting the last lesson holding it. svn path=/branches/work/kdeedu_parley/libkdeedu/; revision=748955 --- diff --git a/keduvocdocument/keduvoclesson.cpp b/keduvocdocument/keduvoclesson.cpp index 472242a..60d7d7b 100644 --- a/keduvocdocument/keduvoclesson.cpp +++ b/keduvocdocument/keduvoclesson.cpp @@ -24,31 +24,32 @@ class KEduVocLesson::Private { public: - ~Private(); - // entries QList m_entries; }; -KEduVocLesson::Private::~ Private() -{ - ///@todo delete children here???? is this a 1:1 mapping? - qDeleteAll(m_entries); -} KEduVocLesson::KEduVocLesson(const QString& name, KEduVocContainer *parent) : d( new Private ), KEduVocContainer(name, Lesson, parent) { } + KEduVocLesson::KEduVocLesson( const KEduVocLesson &other ) : d( new Private ), KEduVocContainer(other) { d->m_entries = other.d->m_entries; } + KEduVocLesson::~KEduVocLesson() { + foreach (KEduVocExpression* entry, d->m_entries) { + entry->removeLesson(this); + if (entry->lessons().count() == 0) { + delete entry; + } + } delete d; } diff --git a/keduvocdocument/keduvoctranslation.cpp b/keduvocdocument/keduvoctranslation.cpp index acf13c5..291733d 100644 --- a/keduvocdocument/keduvoctranslation.cpp +++ b/keduvocdocument/keduvoctranslation.cpp @@ -119,6 +119,9 @@ KEduVocTranslation::KEduVocTranslation( const KEduVocTranslation &other ) : d( n KEduVocTranslation::~KEduVocTranslation() { + if (d->m_wordType) { + d->m_wordType->removeTranslation(this); + } delete d; }