Skip to content

Commit

Permalink
Merge branch 'protect_teardown' into 'master'
Browse files Browse the repository at this point in the history
[qml-plugin-calendar] Protect the calendar manager teardown more. Contributes to JB#51240

See merge request mer-core/nemo-qml-plugin-calendar!62
  • Loading branch information
pvuorela committed Sep 16, 2020
2 parents 1ccc5ee + 84c3233 commit dfeee3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/calendarmanager.cpp
Expand Up @@ -98,9 +98,10 @@ CalendarManager::CalendarManager()
connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
}

static CalendarManager *managerInstance = nullptr;

CalendarManager *CalendarManager::instance(bool createIfNeeded)
{
static CalendarManager *managerInstance;
if (!managerInstance && createIfNeeded)
managerInstance = new CalendarManager;

Expand All @@ -111,6 +112,9 @@ CalendarManager::~CalendarManager()
{
mWorkerThread.quit();
mWorkerThread.wait();
if (managerInstance == this) {
managerInstance = nullptr;
}
}

QList<CalendarData::Notebook> CalendarManager::notebooks()
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.cpp
Expand Up @@ -97,7 +97,7 @@ class CalendarManagerReleaser: public QObject
// will be destroyed via deleteLater when control returns to the event loop.
// Deleting CalendarManager in NemoCalendarPlugin dtor is not an option
// as it is called after the event loop is stopped.
delete CalendarManager::instance();
delete CalendarManager::instance(false);
}
};

Expand Down

0 comments on commit dfeee3d

Please sign in to comment.