From: Christian Muschick Date: Thu, 17 May 2012 19:52:40 +0000 (+0200) Subject: Fixed bug which multiplied conjugations when saving document X-Git-Tag: v4.8.80^0 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=0e40aa82efc47c39d18d5149877805c72fc0f4a2;p=libqmvoc.git Fixed bug which multiplied conjugations when saving document --- diff --git a/keduvocdocument/keduvocconjugation.cpp b/keduvocdocument/keduvocconjugation.cpp index bb55e77..eb2382b 100644 --- a/keduvocdocument/keduvocconjugation.cpp +++ b/keduvocdocument/keduvocconjugation.cpp @@ -118,10 +118,12 @@ void KEduVocConjugation::toKVTML2(QDomElement & parent, const QString &tense) for ( int num = 0; num <= 2; ++num) { QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); for ( int person = 0; person < 5; ++person) { - if (!conjugation(numbers[num] | persons[person]).isEmpty()) { + KEduVocWordFlags curFlags = numbers[num] | persons[person]; + + if (keys().contains(curFlags) && !conjugation(curFlags).isEmpty()) { QDomElement personElement = domDoc.createElement( KVTML_GRAMMATICAL_PERSON[person] ); numberElement.appendChild(personElement); - conjugation(persons[person] | numbers[num]).toKVTML2(personElement); + conjugation(curFlags).toKVTML2(personElement); } } if (numberElement.hasChildNodes()) { diff --git a/keduvocdocument/keduvocconjugation.h b/keduvocdocument/keduvocconjugation.h index 8777e86..d301953 100644 --- a/keduvocdocument/keduvocconjugation.h +++ b/keduvocdocument/keduvocconjugation.h @@ -50,7 +50,19 @@ public: KEduVocConjugation& operator = ( const KEduVocConjugation& a ); bool operator == ( const KEduVocConjugation& a ) const; + /** + * Returns an existing conjugation object. It is an error and leads to undefined behaviour + * to call this method with flags which are not in the list returned by keys(). + * + * BCI: return a pointer instead of a reference. + * + * @param flags Flags obtained by a previous call to keys() + * @return The existing conjugation object with the specified properties + */ KEduVocText& conjugation(KEduVocWordFlags flags) const; + /** + * Updates or creates the conjugation object for the given word flags. + */ void setConjugation(const KEduVocText& conjugation, KEduVocWordFlags flags); QList keys();