summaryrefslogtreecommitdiffstats
path: root/kresources/caldav/resource.cpp
diff options
context:
space:
mode:
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;
}