Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Ensure that deleted events are in memory
Browse files Browse the repository at this point in the history
When running several delete actions in a row from the calendarapi object,
the storage is reloaded between each delete call. This results in
the memory calendar to be emptied after each delete action. When the
next delete action is arriving, the event to delete is not in memory
anymore and the deletion is aborted.
  • Loading branch information
dcaliste committed Apr 22, 2021
1 parent 12fff76 commit 694e8cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/calendarworker.cpp
Expand Up @@ -118,9 +118,13 @@ void CalendarWorker::storageFinished(mKCal::ExtendedStorage *storage, bool error
void CalendarWorker::deleteEvent(const QString &uid, const QDateTime &recurrenceId, const QDateTime &dateTime)
{
KCalendarCore::Event::Ptr event = mCalendar->event(uid, recurrenceId);

if (!event)
if (!event && mStorage->load(uid, recurrenceId)) {
event = mCalendar->event(uid, recurrenceId);
}
if (!event) {
qDebug() << uid << "event already deleted from DB";
return;
}

if (event->recurs() && dateTime.isValid()) {
// We're deleting an occurrence from a recurring event.
Expand All @@ -137,8 +141,11 @@ void CalendarWorker::deleteEvent(const QString &uid, const QDateTime &recurrence
void CalendarWorker::deleteAll(const QString &uid)
{
KCalendarCore::Event::Ptr event = mCalendar->event(uid);
if (!event && mStorage->loadSeries(uid)) {
event = mCalendar->event(uid);
}
if (!event) {
qWarning() << "Failed to delete event, not found" << uid;
qDebug() << uid << "event already deleted from DB";
return;
}

Expand Down

0 comments on commit 694e8cc

Please sign in to comment.