summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jarvie <djarvie@kde.org>2012-01-26 21:46:22 (GMT)
committerDavid Jarvie <djarvie@kde.org>2012-01-26 21:52:58 (GMT)
commit5f2bb19193a8efcfaa0b2bb7a7308bb2a6534bfe (patch)
tree05cd4980c7a1cfc29a004dd421a5fb12d34cf9ec
parent9d292a85f92babfa0506556cf817f146486e315d (diff)
Prevent multiple simultaneous prompts to update a new calendar format
Backport of a101e62536654ede4cc2f8ac85fca42134be44fd (master)
-rw-r--r--kalarm/Changelog1
-rw-r--r--kalarm/calendarmigrator.cpp25
2 files changed, 19 insertions, 7 deletions
diff --git a/kalarm/Changelog b/kalarm/Changelog
index 415fd09..25ec440 100644
--- a/kalarm/Changelog
+++ b/kalarm/Changelog
@@ -2,6 +2,7 @@ KAlarm Change Log
=== Version 2.8.1 --- 26 January 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.
=== Version 2.8.0 (KDE 4.8.0) --- 16 January 2012 ===
- Use Akonadi as the default calendar access method.
diff --git a/kalarm/calendarmigrator.cpp b/kalarm/calendarmigrator.cpp
index f719f97..5359199 100644
--- a/kalarm/calendarmigrator.cpp
+++ b/kalarm/calendarmigrator.cpp
@@ -111,6 +111,9 @@ class CalendarUpdater : public QObject
CalendarUpdater(const Collection& collection, bool dirResource,
bool ignoreKeepFormat, bool newCollection, QObject* parent);
~CalendarUpdater();
+ // Return whether another instance is already updating this collection
+ bool isDuplicate() const { return mDuplicate; }
+ // Check whether any instance is for the given collection ID
static bool containsCollection(Collection::Id);
public slots:
@@ -120,9 +123,10 @@ class CalendarUpdater : public QObject
static QList<CalendarUpdater*> mInstances;
Akonadi::Collection mCollection;
QObject* mParent;
- bool mDirResource;
- bool mIgnoreKeepFormat;
- bool mNewCollection;
+ const bool mDirResource;
+ const bool mIgnoreKeepFormat;
+ const bool mNewCollection;
+ const bool mDuplicate; // another instance is already updating this collection
};
@@ -380,7 +384,8 @@ CalendarUpdater::CalendarUpdater(const Collection& collection, bool dirResource,
mParent(parent),
mDirResource(dirResource),
mIgnoreKeepFormat(ignoreKeepFormat),
- mNewCollection(newCollection)
+ mNewCollection(newCollection),
+ mDuplicate(containsCollection(collection.id()))
{
mInstances.append(this);
}
@@ -404,7 +409,8 @@ bool CalendarUpdater::update()
{
kDebug() << mCollection.id() << (mDirResource ? "directory" : "file");
bool result = true;
- if (mCollection.hasAttribute<CompatibilityAttribute>())
+ if (!mDuplicate // prevent concurrent updates
+ && mCollection.hasAttribute<CompatibilityAttribute>()) // must know format to update
{
const CompatibilityAttribute* compatAttr = mCollection.attribute<CompatibilityAttribute>();
KACalendar::Compat compatibility = compatAttr->compatibility();
@@ -773,13 +779,18 @@ void CalendarCreator::collectionFetchResult(KJob* j)
break;
}
bool keep = false;
+ bool duplicate = false;
if (!mReadOnly)
{
CalendarUpdater* updater = new CalendarUpdater(collection, dirResource, false, true, this);
+ duplicate = updater->isDuplicate();
keep = !updater->update(); // note that 'updater' will auto-delete when finished
}
- // Record the user's choice of whether to update the calendar
- attr->setKeepFormat(keep);
+ if (!duplicate)
+ {
+ // Record the user's choice of whether to update the calendar
+ attr->setKeepFormat(keep);
+ }
// Update the collection's CollectionAttribute value in the Akonadi database.
// Note that we can't supply 'collection' to CollectionModifyJob since