summaryrefslogtreecommitdiffstats
path: root/kresources/caldav/resource.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 21:22:53 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 21:22:53 +0000
commitb4d7e65ac0fe08b3b408bd3a0209d0fcd4c084fd (patch)
tree2c275072aa6aefc4ead9e9d839da8bcfae46c4fc /kresources/caldav/resource.cpp
parent7ef3b0e2a5e5bc9bf928e989e4f66932be096824 (diff)
downloadtdepim-b4d7e65ac0fe08b3b408bd3a0209d0fcd4c084fd.tar.gz
tdepim-b4d7e65ac0fe08b3b408bd3a0209d0fcd4c084fd.zip
Multi-save on exit fix
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1133001 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/caldav/resource.cpp')
-rw-r--r--kresources/caldav/resource.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/kresources/caldav/resource.cpp b/kresources/caldav/resource.cpp
index 3ab1d358f..2562a8376 100644
--- a/kresources/caldav/resource.cpp
+++ b/kresources/caldav/resource.cpp
@@ -70,6 +70,7 @@ const int ResourceCalDav::DEFAULT_SAVE_POLICY = ResourceCached::SaveDelaye
ResourceCalDav::ResourceCalDav( const KConfig *config ) :
ResourceCached(config)
, readLockout(false)
+ , mAllWritesComplete(false)
, mLock(true)
, mPrefs(NULL)
, mLoader(NULL)
@@ -77,6 +78,7 @@ ResourceCalDav::ResourceCalDav( const KConfig *config ) :
, mProgress(NULL)
, mLoadingQueueReady(true)
, mWritingQueueReady(true)
+ , mWriteRetryTimer(NULL)
{
log("ResourceCalDav(config)");
init();
@@ -89,11 +91,14 @@ ResourceCalDav::ResourceCalDav( const KConfig *config ) :
ResourceCalDav::~ResourceCalDav() {
log("jobs termination");
- // This must save the users data before termination below to prevent data loss...
- doSave();
+ if (mWriteRetryTimer != NULL) {
+ mWriteRetryTimer->stop(); // Unfortunately we cannot do anything at this point; if this timer is still running something is seriously wrong
+ }
+
while ((mWriter->running() == true) || (mWritingQueue.isEmpty() == false) || !mWritingQueueReady) {
- sleep(1);
- qApp->processEvents(QEventLoop::ExcludeUserInput);
+ readLockout = true;
+ sleep(1);
+ qApp->processEvents(QEventLoop::ExcludeUserInput);
}
if (mLoader) {
@@ -122,6 +127,10 @@ ResourceCalDav::~ResourceCalDav() {
delete mPrefs;
}
+bool ResourceCalDav::isSaving() {
+ return (((mWriteRetryTimer != NULL) ? mWriteRetryTimer->isActive() : 0) || (mWriter->running() == true) || (mWritingQueue.isEmpty() == false) || !mWritingQueueReady);
+}
+
/*=========================================================================
| GENERAL METHODS
========================================================================*/
@@ -129,7 +138,7 @@ ResourceCalDav::~ResourceCalDav() {
bool ResourceCalDav::doLoad() {
bool syncCache = true;
- if ((mLoadingQueueReady == false) || (mLoadingQueue.isEmpty() == false) || (mLoader->running() == true)) {
+ if ((mLoadingQueueReady == false) || (mLoadingQueue.isEmpty() == false) || (mLoader->running() == true) || (readLockout == true)) {
return true; // Silently fail; the user has obviously not responded to a dialog and we don't need to pop up more of them!
}
@@ -587,7 +596,11 @@ bool ResourceCalDav::startWriting(const QString& url) {
// modifies the calendar with clearChanges() or similar
// Before these calls are made any existing read (and maybe write) threads should be finished
if ((mLoader->running() == true) || (mLoadingQueue.isEmpty() == false) || (mWriter->running() == true) || (mWritingQueue.isEmpty() == false)) {
- QTimer::singleShot( 100, this, SLOT(doSave()) );
+ if (mWriteRetryTimer == NULL) {
+ mWriteRetryTimer = new QTimer(this);
+ connect( mWriteRetryTimer, SIGNAL(timeout()), SLOT(doSave()) );
+ }
+ mWriteRetryTimer->start(1000, TRUE);
return false;
}