[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdesdk/kbabel/catalogmanager
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2005-12-09 21:43:04
Message-ID: 1134164584.988334.15407.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 487248 by goutte:

Fix the new code for saving marks
(It would have been useful to install before testing ...)


 M  +28 -14    catalogmanagerview.cpp  


--- branches/KDE/3.5/kdesdk/kbabel/catalogmanager/catalogmanagerview.cpp \
#487247:487248 @@ -511,36 +511,40 @@
 
 void CatalogManagerView::saveMarks()
 {
-    const KURL url = KFileDialog::getSaveURL( QString(), "*.marklist", this );
-    if( url.isEmpty() ) return;
+    const KURL url2 = KFileDialog::getSaveURL( QString(), "*.marklist", this );
+    if( url2.isEmpty() ) return;
 
-    if ( KIO::NetAccess::exists( url, false, this ) )
+    // ### FIXME: why is the file dialog not doing this?
+    if ( KIO::NetAccess::exists( url2, false, this ) )
     {
         if(KMessageBox::warningContinueCancel(this,QString("<qt>%1</qt>").arg(i18n("The \
                file %1 already exists. "
-	            "Do you want to overwrite \
it?").arg(url.prettyURL())),i18n("Warning"),i18n("&Overwrite"))==KMessageBox::Cancel) \
+	            "Do you want to overwrite \
it?").arg(url2.prettyURL())),i18n("Warning"),i18n("&Overwrite"))==KMessageBox::Cancel)
  {
 	    return;
 	}
     }
 
-#if KDE_IS_VERSION( 3, 5, 0 )
+#if KDE_IS_VERSION( 3, 4, 92 )
     // Support for partially remote KIO slave like media:
-    KURL url2( url );
-    url = KIO::NetAccess::MostLocalURL( url2, this );
+    const KURL url ( KIO::NetAccess::mostLocalURL( url2, this ) );
+#else
+    const KURL url ( url2 );
 #endif
+    kdDebug() << "Saving marks: " << url2.prettyURL() << " most-local: " << \
url.prettyURL() << endl;  
     QFile* file = 0;
     KTempFile* tempFile = 0;
     QTextStream* stream = 0;
     bool error = false;
-    
-    if ( url.isLocalFile() )
+
+    const bool localFile = url.isLocalFile();
+    if ( localFile )
     {
         // We have a local file
         file = new QFile( url.path() );
         if ( file->open (IO_WriteOnly) )
         {
-            stream = new QTextStream();
+            stream = new QTextStream( file );
         }
         else
         {
@@ -567,8 +571,9 @@
         KMessageBox::error( this,
             i18n( "An error occurred while trying to write to file:\n%1\n" ).arg( \
url.prettyURL()) );  }
-    else if ( !url.isLocalFile() )
+    else if ( !localFile )
     {
+        tempFile->close();
         if( !KIO::NetAccess::upload( tempFile->name(), url, this ) )
         {
             // ### KDE4 FIXME: strip the final \n of the message
@@ -576,9 +581,18 @@
                 i18n("An error occurred while trying to upload the \
file:\n%1\n").arg(url.prettyURL()));  }
     }
-    delete stream;
-    delete file;
-    delete tempFile;
+
+    // We have finished so clean up
+    if ( localFile )
+    {
+        delete stream;
+        file->close();
+        delete file;
+    }
+    else
+    {
+        delete tempFile;
+    }
    
     checkSelected();
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic