Bug 123099 - data loss: Incidence to localdir resource not written after 2 deletes before
Summary: data loss: Incidence to localdir resource not written after 2 deletes before
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: 3.5
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-04 23:22 UTC by Martin Koller
Modified: 2009-02-19 15:18 UTC (History)
2 users (show)

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 Martin Koller 2006-03-04 23:22:16 UTC
Version:           3.5 (using KDE 3.5.1, compiled sources)
Compiler:          gcc version 3.4.3
OS:                Linux (i686) release 2.6.7

A very serious problem, as the user sees newly entered data which is never saved.

I have a localdir resource.
When I add on 1 day 2 events, delete them again, add a third one, the third one is not written to disk! (but is still displayed in the calendar!!)

My tests show that this only happens after 2 deletes.
When I only add 1, delete it, add 1, it works.

I activated debug flag 5800: Here is what I get:

I add incidence 'aaa':

libkcal: CalendarResources::addIncidence0x83667b8
libkcal: CalendarResources::beginChange()
libkcal: CalendarResources::requestSaveTicket()
libkcal: CalendarResource::endChange()
libkcal: CalendarResources::save( Ticket *)
libkcal: tick localdir resource
libkcal: Save resource localdir resource
libkcal: writing '/root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1357684282.490'
libkcal: ICalFormat::save(): /root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1357684282.490
libkcal: Write recurrence for 'aaa' (KOrganizer-1357684282.490)
libkcal: CalendarResource::endChange()
korganizer: ERROR: Can't decrement change count. It already is 0.
libkcal: CalendarResources::save( Ticket *)

I delete it:

libkcal: CalendarResources::beginChange()
libkcal: CalendarResources::requestSaveTicket()
libkcal: CalendarResources::deleteEvent
libkcal: ResourceLocalDir::deleteEvent
libkcal: CalendarResource::endChange()

I add a second one (this is now saved) 'bbb':

libkcal: CalendarResources::addIncidence0x83667b8
libkcal: CalendarResources::beginChange()
libkcal: CalendarResource::endChange()
libkcal: CalendarResource::endChange()
libkcal: CalendarResources::save( Ticket *)
libkcal: tick localdir resource
libkcal: Save resource localdir resource
libkcal: writing '/root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1800438583.601'
libkcal: ICalFormat::save(): /root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1800438583.601
libkcal: Write recurrence for 'bbb' (KOrganizer-1800438583.601)

I add another one (which is also saved) 'ccc':

libkcal: CalendarResources::addIncidence0x83667b8
libkcal: CalendarResources::beginChange()
libkcal: CalendarResources::requestSaveTicket()
libkcal: CalendarResource::endChange()
libkcal: CalendarResources::save( Ticket *)
libkcal: tick localdir resource
libkcal: Save resource localdir resource
libkcal: writing '/root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1225803500.72'
libkcal: ICalFormat::save(): /root/.kde/share/apps/korganizer/cal_dir//KOrganizer-1225803500.72
libkcal: Write recurrence for 'ccc' (KOrganizer-1225803500.72)
libkcal: CalendarResource::endChange()
korganizer: ERROR: Can't decrement change count. It already is 0.
libkcal: CalendarResources::save( Ticket *)

I delete 'ccc' and 'bbb':

libkcal: CalendarResources::beginChange()
libkcal: CalendarResources::requestSaveTicket()
libkcal: CalendarResources::deleteEvent
libkcal: ResourceLocalDir::deleteEvent
libkcal: CalendarResource::endChange()
libkcal: CalendarResources::beginChange()
libkcal: CalendarResources::deleteEvent
libkcal: ResourceLocalDir::deleteEvent
libkcal: CalendarResource::endChange()

Now I add another one 'ddd' which is NOT SAVED:

libkcal: CalendarResources::addIncidence0x83667b8
libkcal: CalendarResources::beginChange()
libkcal: CalendarResource::endChange()
libkcal: CalendarResource::endChange()
Comment 1 Martin Koller 2006-03-05 00:21:39 UTC
Looking for the bug in the code, I found something:

When an Incidence is deleted, beginChange() is called before deleteEvent() and then endChange(). In beginChange() a change counter (associated with the Resource the incidence is in) is increased, but in endChange(), the resource the now deleted incidence was in, is no longer found (which is obvious) which leads to the fact, that the changeCounter can not be decreased anymore.

Which further leads to the fact that with the next creation of an incidence the change counter is not set to 0 in endChange() which then does not trigger the save() method.

Adding additional debug outputs shows:

libkcal: CalendarResources::beginChange() 0x8605590
libkcal: int KCal::CalendarResources::incrementChangeCount(KCal::ResourceCalendar*) change count=1
libkcal: CalendarResources::requestSaveTicket()
libkcal: CalendarResources::deleteEvent
libkcal: ResourceLocalDir::deleteEvent
libkcal: CalendarResource::endChange() 0x8605590

libkcal: CalendarResources::beginChange() 0x82bef48
libkcal: int KCal::CalendarResources::incrementChangeCount(KCal::ResourceCalendar*) change count=2
libkcal: CalendarResources::deleteEvent
libkcal: ResourceLocalDir::deleteEvent
libkcal: CalendarResource::endChange() 0x82bef48


As I don't know what is the concept behind the changeCounter, I can't quickly create a solution.
Probably someone can do it with my findings ...
Comment 2 Reinhold Kainhofer 2006-11-02 19:26:08 UTC
Reassigning all KOrganizer bug reports and wishes to the newly created 
korganizer-devel mailing list.
Comment 3 Sebastien Renard 2007-12-02 20:03:00 UTC
I confirm frequent data loss (event and todos) with KOrganizer. Items are ok on the screen, but if I quit and start kontact those items are gone...
I use a localdir resource too.
Hope that this will be fixed in KDE4.
Comment 4 Brian Guthrie 2008-04-26 02:15:28 UTC
I tried to reproduce this, but when I tried to add an event after deleting 2 I was given an popup error saying 'unable to save'.
Comment 5 FiNeX 2008-11-06 14:30:38 UTC
@Brian: which version did you used?  3.5?

Anyway I cannot reproduce using korganizer in KDE 3.5.10.
I've tested current trunk too, which saves correctly events (even if the display is not ever refreshed).
Comment 6 Martin Koller 2008-11-21 16:31:42 UTC
I can still reproduce using KDE 3.5.10.
Just add 2 events, e.g. called 1 and 2, then delete 1 and 2.
Create a new one called 3. Quit korganizer, start it again -> 3 is not there
(It would really make me wonder if the bug is solved in a 3.5.x release, as nobody is working on this anymore ...)
Comment 7 Sergio Martins 2009-02-19 15:18:09 UTC
This bug was fixed in trunk 3 days ago - commit 926668