summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jarvie <djarvie@kde.org>2012-02-11 11:35:07 (GMT)
committerDavid Jarvie <djarvie@kde.org>2012-02-11 11:36:46 (GMT)
commit8b8890cecd3d066f7454b17b113c748cbef53c96 (patch)
tree458663a502bb785ce662ee8d24c1f51a535072dc
parentceedfb8a4b8e493ba55e57f86fcdc5b631949138 (diff)
Bug 293208: fix errors creating default resources on initialisation
Wait for Akonadi server to be fully running before creating default KAlarm resources. This also requires kdepimlibs commit d612b6055f725c01664e3ed07294d2f29052d204 by Volker Krause which fixes the server manager reporting prematurely that it is running. Backport of ce1caef4ca48171855bdb16f9263622fd1660119 (master) BUG:293208 FIXED-IN:4.8.1
-rw-r--r--kalarm/Changelog3
-rw-r--r--kalarm/akonadimodel.cpp26
-rw-r--r--kalarm/akonadimodel.h3
3 files changed, 26 insertions, 6 deletions
diff --git a/kalarm/Changelog b/kalarm/Changelog
index c0ac3ee..80e3465 100644
--- a/kalarm/Changelog
+++ b/kalarm/Changelog
@@ -1,9 +1,10 @@
KAlarm Change Log
-=== Version 2.8.1 --- 4 February 2012 ===
+=== Version 2.8.1 --- 11 February 2012 ===
- [Akonadi] Don't give option to save new alarms in old format calendars.
- [Akonadi] Prevent duplicate prompts to update format of new calendar resource.
- [Akonadi] Automatically disable duplicated calendar resources.
+- [Akonadi] Fix errors when creating default calendar resources.
=== Version 2.8.0 (KDE 4.8.0) --- 16 January 2012 ===
- Use Akonadi as the default calendar access method.
diff --git a/kalarm/akonadimodel.cpp b/kalarm/akonadimodel.cpp
index 9a2de2e..9c9afff 100644
--- a/kalarm/akonadimodel.cpp
+++ b/kalarm/akonadimodel.cpp
@@ -91,7 +91,8 @@ AkonadiModel* AkonadiModel::instance()
*/
AkonadiModel::AkonadiModel(ChangeRecorder* monitor, QObject* parent)
: EntityTreeModel(monitor, parent),
- mMonitor(monitor)
+ mMonitor(monitor),
+ mResourcesChecked(false)
{
// Set lazy population to enable the contents of unselected collections to be ignored
setItemPopulationStrategy(LazyPopulation);
@@ -136,10 +137,25 @@ AkonadiModel::AkonadiModel(ChangeRecorder* monitor, QObject* parent)
connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
connect(monitor, SIGNAL(itemChanged(Akonadi::Item,QSet<QByteArray>)), SLOT(slotMonitoredItemChanged(Akonadi::Item,QSet<QByteArray>)));
- // If necessary, migrate any KResources alarm calendars from pre-Akonadi
- // versions of KAlarm, or create default Akonadi calendar resources if any
- // are missing.
- CalendarMigrator::execute();
+ connect(ServerManager::self(), SIGNAL(stateChanged(Akonadi::ServerManager::State)),
+ SLOT(checkResources(Akonadi::ServerManager::State)));
+ checkResources(ServerManager::state());
+}
+
+/******************************************************************************
+* Called when the server manager is running, i.e. the agent manager knows about
+* all existing resources.
+* Once it is running, if necessary migrate any KResources alarm calendars from
+* pre-Akonadi versions of KAlarm, or create default Akonadi calendar resources
+* if any are missing.
+*/
+void AkonadiModel::checkResources(ServerManager::State state)
+{
+ if (!mResourcesChecked && state == ServerManager::Running)
+ {
+ mResourcesChecked = true;
+ CalendarMigrator::execute();
+ }
}
/******************************************************************************
diff --git a/kalarm/akonadimodel.h b/kalarm/akonadimodel.h
index ca51ea2..8517a27 100644
--- a/kalarm/akonadimodel.h
+++ b/kalarm/akonadimodel.h
@@ -25,6 +25,7 @@
#include <kalarmcal/kaevent.h>
#include <akonadi/entitytreemodel.h>
+#include <akonadi/servermanager.h>
#include <QSize>
#include <QColor>
@@ -233,6 +234,7 @@ class AkonadiModel : public Akonadi::EntityTreeModel
virtual int entityColumnCount(HeaderGroup) const;
private slots:
+ void checkResources(Akonadi::ServerManager::State);
void slotCollectionChanged(const Akonadi::Collection& c, const QSet<QByteArray>& attrNames)
{ setCollectionChanged(c, attrNames, false); }
void slotCollectionRemoved(const Akonadi::Collection&);
@@ -312,6 +314,7 @@ class AkonadiModel : public Akonadi::EntityTreeModel
QList<Akonadi::Collection::Id> mCollectionsDeleting; // collections currently being removed
QList<Akonadi::Collection::Id> mCollectionsDeleted; // collections recently removed
QQueue<Event> mPendingEventChanges; // changed events with changedEvent() signal pending
+ bool mResourcesChecked; // whether resource existence has been checked yet
};
#endif // AKONADIMODEL_H