Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Always return stored CalendarEvent object …
Browse files Browse the repository at this point in the history
…even if not part of any notebook anymore.

The CalendarEvent objects created by the manager are stored in
the mEventObjects private array. This array is always growing.
When an event is not listed anymore in the mEvents array
because the notebook it belongs to is not visible anymore,
fetching its CalendarEvent object should still be valid.
So move the array search before checking that the event is
currently part of any notebook.
  • Loading branch information
dcaliste committed Jun 9, 2020
1 parent 483c858 commit 9252009
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/calendarmanager.cpp
Expand Up @@ -135,16 +135,16 @@ void CalendarManager::setDefaultNotebook(const QString &notebookUid)

CalendarEvent* CalendarManager::eventObject(const QString &eventUid, const KDateTime &recurrenceId)
{
CalendarData::Event event = getEvent(eventUid, recurrenceId);
if (event.isValid()) {
QMultiHash<QString, CalendarEvent *>::iterator it = mEventObjects.find(eventUid);
while (it != mEventObjects.end() && it.key() == eventUid) {
if ((*it)->recurrenceId() == recurrenceId) {
return *it;
}
++it;
QMultiHash<QString, CalendarEvent *>::iterator it = mEventObjects.find(eventUid);
while (it != mEventObjects.end() && it.key() == eventUid) {
if ((*it)->recurrenceId() == recurrenceId) {
return *it;
}
++it;
}

CalendarData::Event event = getEvent(eventUid, recurrenceId);
if (event.isValid()) {
CalendarEvent *calendarEvent = new CalendarEvent(this, eventUid, recurrenceId);
mEventObjects.insert(eventUid, calendarEvent);
return calendarEvent;
Expand Down

0 comments on commit 9252009

Please sign in to comment.