Commit 541940dc authored by David Jarvie's avatar David Jarvie
Browse files

Fix crash on restart after quitting with message windows still open.

parent 8aec312f
......@@ -234,14 +234,19 @@ QVariant CollectionListModel::data(const QModelIndex& index, int role) const
= which are disabled for that alarm type, are unchecked.
=============================================================================*/
#ifdef __GNUC__
#warning Quit with message windows open, restart -> all collections unticked
#endif
CollectionListModel* CollectionCheckListModel::mModel = 0;
int CollectionCheckListModel::mInstanceCount = 0;
CollectionCheckListModel::CollectionCheckListModel(KAlarm::CalEvent::Type type, QObject* parent)
: KCheckableProxyModel(parent),
mAlarmType(type)
{
++mInstanceCount;
if (!mModel)
mModel = new CollectionListModel(this);
mModel = new CollectionListModel(0);
setSourceModel(mModel); // the source model is NOT filtered by alarm type
mSelectionModel = new QItemSelectionModel(mModel);
setSelectionModel(mSelectionModel);
......@@ -258,6 +263,15 @@ CollectionCheckListModel::CollectionCheckListModel(KAlarm::CalEvent::Type type,
SLOT(collectionStatusChanged(Akonadi::Collection,AkonadiModel::Change,QVariant,bool)));
}
CollectionCheckListModel::~CollectionCheckListModel()
{
if (--mInstanceCount <= 0)
{
delete mModel;
mModel = 0;
}
}
/******************************************************************************
* Return the collection for a given row.
*/
......
......@@ -75,6 +75,7 @@ class CollectionCheckListModel : public KCheckableProxyModel
Q_OBJECT
public:
explicit CollectionCheckListModel(KAlarm::CalEvent::Type, QObject* parent = 0);
~CollectionCheckListModel();
Akonadi::Collection collection(int row) const;
Akonadi::Collection collection(const QModelIndex&) const;
virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
......@@ -92,6 +93,7 @@ class CollectionCheckListModel : public KCheckableProxyModel
void setSelectionStatus(const Akonadi::Collection&, const QModelIndex&);
static CollectionListModel* mModel;
static int mInstanceCount;
KAlarm::CalEvent::Type mAlarmType; // alarm type contained in this model
QItemSelectionModel* mSelectionModel;
};
......
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