Bug 86401 - Data is saved after korganizer exit even without any changes
Summary: Data is saved after korganizer exit even without any changes
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: 3.2.1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Cornelius Schumacher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-02 00:30 UTC by temp1.neufrank
Modified: 2004-09-15 00:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description temp1.neufrank 2004-08-02 00:30:26 UTC
Version:           3.2.1 (using KDE 3.2.3, compiled sources)
Compiler:          gcc version 3.2
OS:                Linux (i686) release 2.4.24

I use korganizer on my notebook and my desktop and try to keep the active calender alike by running unison after I changed one source.

After upgrading to 3.2.1 I noticed that the active calender is saved even without doing any changes. This has the result that I can not decide which file (on notebook or desktop) contains the changed data and which was only visited to read some entries.

So far I can see no use of this new feature (saving non existing changes)...

Regards,

Frank
Comment 1 Reinhold Kainhofer 2004-09-15 00:40:53 UTC
CVS commit by kainhofe: 

Properly add Observers to CalendarResources. This also makes it possible to watch changes of all incidences, and so only save the calendar if it was changed at all.

CCMAIL: 86401-done@bugs.kde.org


  M +9 -10     calendarlocal.cpp   1.65
  M +19 -7     calendarresources.cpp   1.51
  M +0 -6      calendarresources.h   1.39
  M +0 -2      resourcelocal.cpp   1.30


--- kdepim/libkcal/calendarlocal.cpp  #1.64:1.65
@@ -74,5 +74,4 @@ bool CalendarLocal::save( const QString 
         // Save only if the calendar is either modified, or saved to a 
         // different file than it was loaded from
-kdDebug()<<"CalendarLocal::save(), fileName="<<fileName<<", mFileName="<<mFileName<<", isModified="<<isModified()<<endl;
         if ( mFileName != fileName || isModified() ) {
     FileStorage storage( this, fileName, format );

--- kdepim/libkcal/calendarresources.cpp  #1.50:1.51
@@ -131,4 +131,10 @@ void CalendarResources::load()
   for ( it = mManager->activeBegin(); it != mManager->activeEnd(); ++it ) {
     (*it)->load();
+    Incidence::List incidences = (*it)->rawIncidences();
+    Incidence::List::Iterator incit;
+    for ( incit = incidences.begin(); incit != incidences.end(); ++incit ) {
+      (*incit)->registerObserver( this );
+      notifyIncidenceAdded( *incit );
+    }
   }
 
@@ -165,5 +171,5 @@ void CalendarResources::save()
   kdDebug(5800) << "CalendarResources::save()" << endl;
 
-  if ( mOpen ) {
+  if ( mOpen && isModified() ) {
     CalendarResourceManager::ActiveIterator it;
     for ( it = mManager->activeBegin(); it != mManager->activeEnd(); ++it ) {
@@ -189,5 +195,5 @@ bool CalendarResources::isSaving()
 bool CalendarResources::addIncidence( Incidence *incidence )
 {
-  kdDebug(5800) << "CalendarResources::addIncidence" << endl;
+  kdDebug(5800) << "CalendarResources::addIncidence" << this << endl;
 
   ResourceCalendar *resource = mDestinationPolicy->destination( incidence );
@@ -195,4 +201,8 @@ bool CalendarResources::addIncidence( In
   if ( resource ) {
     if ( resource->addIncidence( incidence ) ) {
+      incidence->registerObserver( this );
+      notifyIncidenceAdded( incidence );
+      
+
       mResourceMap[ incidence ] = resource;
       setModified( true );
@@ -219,4 +229,6 @@ bool CalendarResources::addEvent( Event 
   if ( validRes && resource->addEvent( anEvent ) ) {
     mResourceMap[anEvent] = resource;
+    anEvent->registerObserver( this );
+    notifyIncidenceAdded( anEvent );
     setModified( true );
     return true;
@@ -278,4 +290,6 @@ bool CalendarResources::addTodo(Todo *to
   if ( validRes && resource->addTodo( todo ) ) {
     mResourceMap[todo] = resource;
+    todo->registerObserver( this );
+    notifyIncidenceAdded( todo );
     setModified( true );
     return true;
@@ -518,4 +532,6 @@ bool CalendarResources::addJournal(Journ
   if ( validRes && resource->addJournal( journal ) ) {
     mResourceMap[journal] = resource;
+    journal->registerObserver( this );
+    notifyIncidenceAdded( journal );
     setModified( true );
     return true;
@@ -588,9 +604,4 @@ Journal::List CalendarResources::journal
 
 
-void CalendarResources::incidenceUpdated( IncidenceBase * )
-{
-  kdDebug(5800) << "CalendarResources::incidenceUpdated( IncidenceBase * ): Not yet implemented\n";
-}
-
 void CalendarResources::connectResource( ResourceCalendar *resource )
 {
@@ -673,4 +684,5 @@ bool CalendarResources::save( Ticket *ti
   kdDebug(5800) << "tick " << ticket->resource()->resourceName() << endl;
 
+        // @TODO: Check if the resource was changed at all. If not, don't save.
   if ( ticket->resource()->save() ) {
     releaseSaveTicket( ticket );

--- kdepim/libkcal/calendarresources.h  #1.38:1.39
@@ -250,10 +250,4 @@ class CalendarResources : public Calenda
     void signalErrorMessage( const QString & );
 
-  protected:
-    /**
-      The observer interface. So far not implemented.
-    */
-    void incidenceUpdated( IncidenceBase * );
-
   public:
     /**

--- kdepim/libkcal/resourcelocal.cpp  #1.29:1.30
@@ -159,7 +159,5 @@ bool ResourceLocal::doLoad()
 bool ResourceLocal::doSave()
 {
-kdDebug()<<"ResourceLoadl::doSave"<<endl;
   bool success = mCalendar.save( mURL.path() );
-kdDebug()<<"ResourceLocal::doSave, success="<<success<<endl;
   d->mLastModified = readLastModified();