Commit 694e8cce authored by Damien Caliste's avatar Damien Caliste

[nemo-qml-plugin-calendar] Ensure that deleted events are in memory

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.
parent 12fff76a
......@@ -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.
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment