From 9ca2cd947f22d33543e065f54c6487e86d80befa Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 30 Jul 2005 14:43:57 +0000 Subject: fixxx --- (limited to 'libkcal/calendar.cpp') diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index b7990d4..b1806ee 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -110,9 +110,28 @@ void Calendar::init() Calendar::~Calendar() { delete mDefaultFilter; - if ( mUndoIncidence ) - delete mUndoIncidence; -} + clearUndo( 0 ); +} +void Calendar::clearUndo( Incidence * newUndo ) +{ + + if ( mUndoIncidence ) { + if ( mUndoIncidence->typeID() == eventID ) + delete ((Event*) mUndoIncidence) ; + else if ( mUndoIncidence->typeID() == todoID ) + delete ( (Todo*) mUndoIncidence ); + else if ( mUndoIncidence->typeID() == journalID ) + delete ( (Journal*) mUndoIncidence ); + else + delete mUndoIncidence; + } + mUndoIncidence = newUndo; + if ( mUndoIncidence ) { + mUndoIncidence->clearRelations(); + } + +} + void Calendar::setDontDeleteIncidencesOnClose () { mDeleteIncidencesOnClose = false; @@ -447,7 +466,21 @@ void Calendar::removeRelations( Incidence *incidence ) incidence->relatedTo()->removeRelation( incidence ); // Remove this one from the orphans list - if( mOrphanUids.remove( uid ) ) + if( mOrphanUids.remove( uid ) ) { + QString r2uid = incidence->relatedToUid(); + QPtrList tempList; + while( Incidence* i = mOrphans[ r2uid ] ) { + mOrphans.remove( r2uid ); + if ( i != incidence ) tempList.append( i ); + } + Incidence* inc = tempList.first(); + while ( inc ) { + mOrphans.insert( r2uid, inc ); + inc = tempList.next(); + } + } + // LR: and another big bad bug found +#if 0 // This incidence is located in the orphans list - it should be removed if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { // Removing wasn't that easy @@ -458,6 +491,7 @@ void Calendar::removeRelations( Incidence *incidence ) } } } +#endif } void Calendar::registerObserver( Observer *observer ) -- cgit v0.9.0.2