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

List:       kde-commits
Subject:    branches/KDE/4.3/kdegraphics/okular
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2009-09-13 21:14:05
Message-ID: 1252876445.087847.4754.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1023087 by aacid:

Backport r1023085 | aacid | 2009-09-13 23:11:37 +0200 (Sun, 13 Sep 2009) | 3 lines

Remove special casing for saving local files where we don't use the temporary file, \
fixes saving a pdf file over itself


 M  +18 -36    part.cpp  


--- branches/KDE/4.3/kdegraphics/okular/part.cpp #1023086:1023087
@@ -1483,49 +1483,31 @@
     if ( !saveUrl.isValid() || saveUrl.isEmpty() )
         return;
 
-    if ( saveUrl.isLocalFile() )
+    if ( KIO::NetAccess::exists( saveUrl, KIO::NetAccess::DestinationSide, widget() \
) )  {
-        const QString fileName = saveUrl.toLocalFile();
-        if ( QFile::exists( fileName ) )
-        {
-            if (KMessageBox::warningContinueCancel( widget(), i18n("A file named \
\"%1\" already exists. Are you sure you want to overwrite it?", saveUrl.fileName()), \
                QString(), KGuiItem(i18n("Overwrite"))) != KMessageBox::Continue)
-                return;
-        }
-
-        if ( !m_document->saveChanges( fileName ) )
-        {
-            KMessageBox::information( widget(), i18n("File could not be saved in \
'%1'. Try to save it to another location.", fileName ) ); +        if \
(KMessageBox::warningContinueCancel( widget(), i18n("A file named \"%1\" already \
exists. Are you sure you want to overwrite it?", saveUrl.fileName()), QString(), \
KGuiItem(i18n("Overwrite"))) != KMessageBox::Continue)  return;
-        }
     }
-    else
-    {
-        if ( KIO::NetAccess::exists( saveUrl, KIO::NetAccess::DestinationSide, \
                widget() ) )
-        {
-            if (KMessageBox::warningContinueCancel( widget(), i18n("A file named \
\"%1\" already exists. Are you sure you want to overwrite it?", saveUrl.fileName()), \
                QString(), KGuiItem(i18n("Overwrite"))) != KMessageBox::Continue)
-                return;
-        }
 
-        KTemporaryFile tf;
-        QString fileName;
-        if ( !tf.open() )
-        {
-            KMessageBox::information( widget(), i18n("Could not open the temporary \
                file for saving." ) );
-                return;
-        }
-        fileName = tf.fileName();
-        tf.close();
-
-        if ( !m_document->saveChanges( fileName ) )
-        {
-            KMessageBox::information( widget(), i18n("File could not be saved in \
'%1'. Try to save it to another location.", fileName ) ); +    KTemporaryFile tf;
+    QString fileName;
+    if ( !tf.open() )
+    {
+        KMessageBox::information( widget(), i18n("Could not open the temporary file \
for saving." ) );  return;
-        }
+    }
+    fileName = tf.fileName();
+    tf.close();
 
-        KIO::Job *copyJob = KIO::file_copy( fileName, saveUrl, -1, KIO::Overwrite );
-        if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
-            KMessageBox::information( widget(), i18n("File could not be saved in \
'%1'. Try to save it to another location.", saveUrl.prettyUrl() ) ); +    if ( \
!m_document->saveChanges( fileName ) ) +    {
+        KMessageBox::information( widget(), i18n("File could not be saved in '%1'. \
Try to save it to another location.", fileName ) ); +        return;
     }
+
+    KIO::Job *copyJob = KIO::file_copy( fileName, saveUrl, -1, KIO::Overwrite );
+    if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
+        KMessageBox::information( widget(), i18n("File could not be saved in '%1'. \
Try to save it to another location.", saveUrl.prettyUrl() ) );  }
 
 


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

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