Commit ac7402f5 authored by David Jarvie's avatar David Jarvie
Browse files

Bug 441660: Fix crash when KAlarm is launched while already running

BUG:441660
parent 442027dd
Pipeline #78074 skipped
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.18.1")
set(PIM_VERSION ${PIM_VERSION})
set(RELEASE_SERVICE_VERSION "21.08.1")
set(KALARM_VERSION "3.3.0")
set(KALARM_VERSION "3.3.1")
project(kalarm VERSION ${KALARM_VERSION})
......
KAlarm Change Log
=== Version 3.3.1 (KDE Applications 21.08.1) --- 29 August 2021 ===
* Fix crash when KAlarm is launched while already running [KDE Bug 441660]
=== Version 3.3.0 (KDE Applications 21.08) --- 1 August 2021 ===
* Add date selector option to enable alarm list view to be filtered.
* Show hamburger menu when menu bar is hidden, to allow access to all options.
......
/*
* resourcemodel.cpp - models containing flat list of resources
* Program: kalarm
* SPDX-FileCopyrightText: 2007-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2007-2021 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -448,7 +448,7 @@ QByteArray ResourceCheckListModel::debugType(const char* func) const
= Proxy model providing a checkable resource list, filtered to contain only one
= alarm type. The selected alarm type may be changed as desired.
=============================================================================*/
ResourceFilterCheckListModel* ResourceFilterCheckListModel::mInstance {nullptr};
QVector<ResourceFilterCheckListModel*> ResourceFilterCheckListModel::mInstances;
ResourceFilterCheckListModel::ResourceFilterCheckListModel(QObject* parent)
: QSortFilterProxyModel(parent)
......@@ -459,8 +459,7 @@ ResourceFilterCheckListModel::ResourceFilterCheckListModel(QObject* parent)
ResourceFilterCheckListModel::~ResourceFilterCheckListModel()
{
if (this == mInstance)
mInstance = nullptr;
mInstances.removeAll(this);
}
void ResourceFilterCheckListModel::init()
......@@ -524,11 +523,11 @@ Resource ResourceFilterCheckListModel::resource(const QModelIndex& index) const
void ResourceFilterCheckListModel::disable()
{
if (mInstance)
for (auto instance : std::as_const(mInstances))
{
mInstance->mActiveModel->disable();
mInstance->mArchivedModel->disable();
mInstance->mTemplateModel->disable();
instance->mActiveModel->disable();
instance->mArchivedModel->disable();
instance->mTemplateModel->disable();
}
}
......
/*
* resourcemodel.h - models containing flat list of resources
* Program: kalarm
* SPDX-FileCopyrightText: 2010-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2010-2021 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -177,7 +177,7 @@ class ResourceFilterCheckListModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
/** Constructs the unique instance.
/** Constructs an instance.
* @tparam DataModel The data model class to use as the source model. It must
* have the following methods:
* static DataModel* instance(); - returns the unique instance.
......@@ -208,7 +208,7 @@ private:
explicit ResourceFilterCheckListModel(QObject* parent);
void init();
static ResourceFilterCheckListModel* mInstance;
static QVector<ResourceFilterCheckListModel*> mInstances;
ResourceCheckListModel* mActiveModel {nullptr};
ResourceCheckListModel* mArchivedModel {nullptr};
ResourceCheckListModel* mTemplateModel {nullptr};
......@@ -270,15 +270,14 @@ ResourceCheckListModel* ResourceCheckListModel::create(CalEvent::Type type, QObj
template <class DataModel>
ResourceFilterCheckListModel* ResourceFilterCheckListModel::create(QObject* parent)
{
if (mInstance)
return nullptr;
mInstance = new ResourceFilterCheckListModel(parent);
mInstance->mActiveModel = ResourceCheckListModel::create<DataModel>(CalEvent::ACTIVE, mInstance);
mInstance->mArchivedModel = ResourceCheckListModel::create<DataModel>(CalEvent::ARCHIVED, mInstance);
mInstance->mTemplateModel = ResourceCheckListModel::create<DataModel>(CalEvent::TEMPLATE, mInstance);
mInstance->mTooltipFunction = [](const Resource& r, CalEvent::Types t) { return DataModel::instance()->tooltip(r, t); };
mInstance->init();
return mInstance;
ResourceFilterCheckListModel* instance = new ResourceFilterCheckListModel(parent);
mInstances.append(instance);
instance->mActiveModel = ResourceCheckListModel::create<DataModel>(CalEvent::ACTIVE, instance);
instance->mArchivedModel = ResourceCheckListModel::create<DataModel>(CalEvent::ARCHIVED, instance);
instance->mTemplateModel = ResourceCheckListModel::create<DataModel>(CalEvent::TEMPLATE, instance);
instance->mTooltipFunction = [](const Resource& r, CalEvent::Types t) { return DataModel::instance()->tooltip(r, t); };
instance->init();
return instance;
}
......
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