[rkward-cvs] SF.net SVN: rkward:[3002] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 6 16:43:50 UTC 2010


Revision: 3002
          http://rkward.svn.sourceforge.net/rkward/?rev=3002&view=rev
Author:   tfry
Date:     2010-09-06 16:43:50 +0000 (Mon, 06 Sep 2010)

Log Message:
-----------
KIO file-jobs do not seem to work perfectly on windows. Workaround to make the most important use case work reliably.

Modified Paths:
--------------
    trunk/rkward/rkward/misc/rkjobsequence.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp

Modified: trunk/rkward/rkward/misc/rkjobsequence.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkjobsequence.cpp	2010-09-06 16:42:46 UTC (rev 3001)
+++ trunk/rkward/rkward/misc/rkjobsequence.cpp	2010-09-06 16:43:50 UTC (rev 3002)
@@ -48,7 +48,6 @@
 void RKJobSequence::start () {
 	RK_TRACE (MISC);
 
-	RK_ASSERT (!outstanding_jobs.isEmpty ());
 	nextJob ();
 }
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2010-09-06 16:42:46 UTC (rev 3001)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2010-09-06 16:43:50 UTC (rev 3002)
@@ -389,20 +389,33 @@
 	save.setAutoRemove (false);
 
 	RKJobSequence* alljobs = new RKJobSequence ();
+	// The KJob-Handling below seems to be a bit error-prone, at least for the file-protocol on Windows.
+	// Thus, for the simple case of local files, we use QFile, instead.
 	connect (alljobs, SIGNAL (finished(RKJobSequence*)), this, SLOT (autoSaveHandlerJobFinished(RKJobSequence*)));
 	// backup the old autosave file in case something goes wrong during pushing the new one
 	KUrl backup_autosave_url;
 	if (previous_autosave_url.isValid ()) {
 		backup_autosave_url = previous_autosave_url;
 		backup_autosave_url.setFileName (backup_autosave_url.fileName () + "~");
-		alljobs->addJob (KIO::file_move (previous_autosave_url, backup_autosave_url, -1, KIO::HideProgressInfo | KIO::Overwrite));
+		if (previous_autosave_url.isLocalFile ()) {
+			QFile::remove (backup_autosave_url.toLocalFile ());
+			QFile::copy (previous_autosave_url.toLocalFile (), backup_autosave_url.toLocalFile ());
+		} else {
+			alljobs->addJob (KIO::file_move (previous_autosave_url, backup_autosave_url, -1, KIO::HideProgressInfo | KIO::Overwrite));
+		}
 	}
 	
 	// push the newly written file
 	if (url ().isValid ()) {
 		KUrl autosave_url = url ();
 		autosave_url.setFileName (autosave_url.fileName () + RKSettingsModuleCommandEditor::autosaveSuffix ());
-		alljobs->addJob (KIO::file_move (KUrl::fromLocalFile (save.fileName ()), autosave_url, -1, KIO::HideProgressInfo | KIO::Overwrite));
+		if (autosave_url.isLocalFile ()) {
+			QFile::remove (backup_autosave_url.toLocalFile ());
+			save.copy (backup_autosave_url.toLocalFile ());
+			save.remove ();
+		} else {
+			alljobs->addJob (KIO::file_move (KUrl::fromLocalFile (save.fileName ()), autosave_url, -1, KIO::HideProgressInfo | KIO::Overwrite));
+		}
 		previous_autosave_url = autosave_url;
 	} else {		// i.e., the document is still "Untitled"
 		previous_autosave_url = KUrl::fromLocalFile (save.fileName ());
@@ -410,7 +423,11 @@
 
 	// remove the backup
 	if (backup_autosave_url.isValid ()) {
-		alljobs->addJob (KIO::del (backup_autosave_url, KIO::HideProgressInfo));
+		if (backup_autosave_url.isLocalFile ()) {
+			QFile::remove (backup_autosave_url.toLocalFile ());
+		} else {
+			alljobs->addJob (KIO::del (backup_autosave_url, KIO::HideProgressInfo));
+		}
 	}
 	alljobs->start ();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list