[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/trinity/kdepim/kresources
From: Timothy Pearson <kb9vqf () pearsoncomputing ! net>
Date: 2010-05-31 21:22:53
Message-ID: 20100531212253.7F951AC8C6 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1133001 by tpearson:
Multi-save on exit fix
M +17 -4 caldav/resource.cpp
M +5 -0 caldav/resource.h
M +19 -5 carddav/resource.cpp
M +7 -0 carddav/resource.h
--- branches/trinity/kdepim/kresources/caldav/resource.cpp #1133000:1133001
@@ -70,6 +70,7 @@
ResourceCalDav::ResourceCalDav( const KConfig *config ) :
ResourceCached(config)
, readLockout(false)
+ , mAllWritesComplete(false)
, mLock(true)
, mPrefs(NULL)
, mLoader(NULL)
@@ -77,6 +78,7 @@
, mProgress(NULL)
, mLoadingQueueReady(true)
, mWritingQueueReady(true)
+ , mWriteRetryTimer(NULL)
{
log("ResourceCalDav(config)");
init();
@@ -89,9 +91,12 @@
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) { + readLockout = true;
sleep(1);
qApp->processEvents(QEventLoop::ExcludeUserInput);
}
@@ -122,6 +127,10 @@
delete mPrefs;
}
+bool ResourceCalDav::isSaving() {
+ return (((mWriteRetryTimer != NULL) ? mWriteRetryTimer->isActive() : 0) || \
(mWriter->running() == true) || (mWritingQueue.isEmpty() == false) || \
!mWritingQueueReady); +}
+
/*=========================================================================
| GENERAL METHODS
========================================================================*/
@@ -129,7 +138,7 @@
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 @@
// 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;
}
--- branches/trinity/kdepim/kresources/caldav/resource.h #1133000:1133001
@@ -69,6 +69,8 @@
virtual void setReadOnly(bool v);
+ bool isSaving();
+
protected slots:
void loadFinished();
@@ -211,6 +213,7 @@
static const int DEFAULT_SAVE_POLICY;
bool readLockout;
+ bool mAllWritesComplete;
// members: ===============================================================
@@ -226,6 +229,8 @@
bool mWritingQueueReady;
QPtrQueue<WritingTask> mWritingQueue;
+ QTimer *mWriteRetryTimer;
+
};
--- branches/trinity/kdepim/kresources/carddav/resource.cpp #1133000:1133001
@@ -70,12 +70,15 @@
ResourceCardDav::ResourceCardDav( const KConfig *config ) :
ResourceCached(config)
, mLock(true)
+ , readLockout(false)
+ , mAllWritesComplete(false)
, mPrefs(NULL)
, mLoader(NULL)
, mWriter(NULL)
, mProgress(NULL)
, mLoadingQueueReady(true)
, mWritingQueueReady(true)
+ , mWriteRetryTimer(NULL)
{
log("ResourceCardDav(config)");
init();
@@ -88,9 +91,12 @@
ResourceCardDav::~ResourceCardDav() {
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) { + readLockout = true;
sleep(1);
qApp->processEvents(QEventLoop::ExcludeUserInput);
}
@@ -121,6 +127,10 @@
delete mPrefs;
}
+bool ResourceCardDav::isSaving() {
+ return (((mWriteRetryTimer != NULL) ? mWriteRetryTimer->isActive() : 0) || \
(mWriter->running() == true) || (mWritingQueue.isEmpty() == false) || \
!mWritingQueueReady); +}
+
/*=========================================================================
| GENERAL METHODS
========================================================================*/
@@ -128,7 +138,7 @@
bool ResourceCardDav::load() {
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! }
@@ -361,7 +371,7 @@
data.replace('\r', '\n');
log("trying to parse...");
- //printf("PARSING:\n\r%s\n\r", data.ascii());
+ printf("PARSING:\n\r%s\n\r", data.ascii());
if (parseData(data)) {
// FIXME: The agenda view can crash when a change is
// made on a remote server and a reload is requested!
@@ -566,7 +576,11 @@
// 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;
}
--- branches/trinity/kdepim/kresources/carddav/resource.h #1133000:1133001
@@ -71,6 +71,8 @@
virtual void setReadOnly(bool v);
+ bool isSaving();
+
protected slots:
void loadFinished();
@@ -190,6 +192,9 @@
static const int DEFAULT_RELOAD_POLICY;
static const int DEFAULT_SAVE_POLICY;
+ bool readLockout;
+ bool mAllWritesComplete;
+
// members: ===============================================================
KABC::LockNull mLock;
@@ -204,6 +209,8 @@
bool mWritingQueueReady;
QPtrQueue<WritingTask> mWritingQueue;
+ QTimer *mWriteRetryTimer;
+
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic