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

List:       kde-core-devel
Subject:    Re: KParts::ReadWritePart
From:       Matthias Kretz <kretz () kde ! org>
Date:       2002-01-24 17:01:31
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 24 January 2002 16:59, David Faure wrote:
> Oops. Should be set to false again at the end of slotUploadFinished
> (unconditionnally). Hmm, not good enough (for local files this isn't
> called). Reimplemented openURL and set it to false there.

OK. Now I have another problem. I reimplemented openURL in my part so that I 
can use a KIO::get job. But I can't set m_bClosing from there.
Can't we set m_bClosing to false in saveToURL and slotUploadFinished?
=> see attached patch

- -- 
C'ya
        Matthias
________________________________________________________
Matthias Kretz (Germany)
http://Vir.homeip.net/
MatthiasKretz@gmx.net, kretz@kde.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8UD3uyg4WnCj6OIoRAnkuAKCU1x5cb5cLv1po9D7CU5ijUWLvnQCgx3ae
AAyLr0W5nvZFM00pcx2WsxI=
=qGwh
-----END PGP SIGNATURE-----

["part.cpp.patch" (text/x-diff)]

Index: part.cpp
===================================================================
RCS file: /home/kde/kdelibs/kparts/part.cpp,v
retrieving revision 1.105
diff -u -3 -p -r1.105 part.cpp
--- part.cpp	2002/01/21 00:08:13	1.105
+++ part.cpp	2002/01/24 16:55:35
@@ -446,10 +453,11 @@ bool ReadWritePart::closeURL()
       {
           KURL url = KFileDialog::getSaveURL();
           if (url.isEmpty()) return false;
-          return saveAs( url ) && ReadOnlyPart::closeURL();
+          return saveAs( url );
       }
-      return save() && ReadOnlyPart::closeURL();
+      return save();
     case KMessageBox::No :
+      setModified( false ); // the user isn't interested in the changes, forget them
       return true;
     default : // case KMessageBox::Cancel :
       return false;
@@ -503,6 +511,12 @@ bool ReadWritePart::saveToURL()
   {
     setModified( false );
     emit completed();
+    if ( m_bClosing && m_bTemp ) // We're finished with this document -> remove temp file
+    {
+      unlink( QFile::encodeName(m_file) );
+      m_bTemp = false;
+    }
+    m_bClosing = false; // temp file was cleaned up
     return true; // Nothing to do
   }
   else
@@ -520,10 +534,14 @@ void ReadWritePart::slotUploadFinished( 
   else
   {
     setModified( false );
-    if ( m_bClosing )
-      ReadOnlyPart::closeURL();
+    if ( m_bClosing && m_bTemp ) // We're finished with this document -> remove temp file
+    {
+      unlink( QFile::encodeName(m_file) );
+      m_bTemp = false;
+    }
     emit completed();
   }
+  m_bClosing = false; // temp file was cleaned up
 }
 
 #include "part.moc"


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

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