OSSP CVS Repository

ossp - Difference in ossp-pkg/as/as-gui/as_slot.cpp versions 1.89 and 1.90
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/as/as-gui/as_slot.cpp 1.89 -> 1.90

--- as_slot.cpp  2003/01/27 14:43:44     1.89
+++ as_slot.cpp  2003/01/27 17:56:56     1.90
@@ -34,6 +34,7 @@
 #include <qcombobox.h>
 #include <qclipboard.h>
 #include <qmenudata.h>
+#include <qdatastream.h>
 //#include <qregexp.h>
 
 // User interface
@@ -384,16 +385,33 @@
 void Titraqform::saveFile(void)
 {
     QString Fname;
+    QFile Filevents, Filebak;
+    QTextStream Streamevents, Streambak;
+
     try {
         Fname = QString(*this->getFilename());
+
         // First time saves are really just saveAs in disguise
         if (Fname.isEmpty()) {
             this->saveAs();
             return;
         }
-        // Try to open a file for writing to
-        QFile Filetemp(Fname);
-        this->saveData(Filetemp); // Pass to helper method
+
+        Filevents.setName(Fname); // Construct a file to back up and write
+
+        // Make a backup before overwriting
+        if (Filevents.exists()) {
+            Filevents.open(IO_ReadOnly);
+            Filebak.setName(Fname + ".bak");
+            Filebak.open(IO_WriteOnly);
+            Streamevents.setDevice(&Filevents);
+            Streambak.setDevice(&Filebak);
+            Streambak << Streamevents.read();
+            Filevents.close();
+            Filebak.close();
+        }
+
+        this->saveData(Filevents); // Pass to helper method
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();

CVSTrac 2.0.1