Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv28841/src/gui

Modified Files:
        wxComposeView.cpp wxMApp.cpp 
Log Message:
save unsaved messages when the program crashes

Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.263
retrieving revision 1.264
diff -b -u -2 -r1.263 -r1.264
--- wxComposeView.cpp   28 Mar 2002 15:26:39 -0000      1.263
+++ wxComposeView.cpp   28 Mar 2002 23:13:04 -0000      1.264
@@ -3636,12 +3636,15 @@
 }
 
-bool Composer::SaveAll()
+int Composer::SaveAll()
 {
-   bool rc = true;
+   int rc = 0;
    for ( ComposerList::iterator i = gs_listOfAllComposers.begin();
          i != gs_listOfAllComposers.end();
          ++i )
    {
-      rc &= (*i)->AutoSave();
+      if ( (*i)->AutoSave() )
+         rc++;
+      else
+         rc = -1;
    }
 

Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.225
retrieving revision 1.226
diff -b -u -2 -r1.225 -r1.226
--- wxMApp.cpp  18 Mar 2002 22:39:28 -0000      1.225
+++ wxMApp.cpp  28 Mar 2002 23:13:04 -0000      1.226
@@ -133,4 +133,22 @@
 
 // ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+/**
+  Tries to save all unsaved stuff which the user wouldn't like to lose
+ */
+static int SaveAll()
+{
+   int rc = Composer::SaveAll();
+
+   Profile::FlushAll();
+
+   MfStatusCache::Flush();
+
+   return rc;
+}
+
+// ----------------------------------------------------------------------------
 // classes
 // ----------------------------------------------------------------------------
@@ -181,9 +199,5 @@
       wxLogTrace(TRACE_TIMER, "Autosaving options and folder status.");
 
-      Composer::SaveAll();
-
-      Profile::FlushAll();
-
-      MfStatusCache::Flush();
+      (void)SaveAll();
    }
 
@@ -503,5 +517,25 @@
    MAppBase::OnAbnormalTermination();
 
-   static const char *msg =
+   // try to save the unsaved messages and options
+   int nSaved = SaveAll();
+
+   wxString msg;
+   switch ( nSaved )
+   {
+      case -1:
+         msg = _("Not all composer windows could be saved.");
+         break;
+
+      case 0:
+         // leave empty
+         break;
+
+      default:
+         msg.Printf(_("%d unsaved messages were saved,\n"
+                      "they will be restored on the next program startup."),
+                    nSaved);
+   }
+
+   static const char *msgCrash =
       gettext_noop("The application is terminating abnormally.\n"
                    "\n"
@@ -514,4 +548,11 @@
                    "Thank you!");
    static const char *title = gettext_noop("Fatal application error");
+
+   if ( !msg.empty() )
+   {
+      msg += "\n\n";
+   }
+
+   msg += msgCrash;
 
    // using a plain message box is safer in this situation, but under Unix we


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to