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

Modified Files:
        wxMApp.cpp wxMainFrame.cpp 
Log Message:
modified the program exiting logic to behave in the same way whether it
exits because of a menu command or because the main frame was closed


Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.230
retrieving revision 1.231
diff -b -u -2 -r1.230 -r1.231
--- wxMApp.cpp  15 Apr 2002 19:46:06 -0000      1.230
+++ wxMApp.cpp  15 Apr 2002 23:45:13 -0000      1.231
@@ -603,5 +603,5 @@
    // if it was TRUE (if we couldn't close before, may be we can now)
    if ( m_CanClose )
-      return m_CanClose;
+      return true;
 
    // verify that the user didn't accidentally remembered "No" as the answer to
@@ -623,15 +623,21 @@
 
    // ask the user for confirmation
-   if ( !MDialog_YesNoDialog(_("Do you really want to exit Mahogany?"),
+   bool rc = MDialog_YesNoDialog
+             (
+               _("Do you really want to exit Mahogany?"),
                               m_topLevelFrame,
                               MDIALOG_YESNOTITLE,
                               M_DLG_YES_DEFAULT | M_DLG_NOT_ON_NO,
-                              M_MSGBOX_CONFIRM_EXIT) )
+               M_MSGBOX_CONFIRM_EXIT
+             );
+
+   if ( rc )
    {
+      // now check for anything else which may require the user intervention
+      if ( !MAppBase::CanClose() )
       return false;
-   }
 
    wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
-   while ( node )
+      while ( node && rc )
    {
       wxWindow *win = node->GetData();
@@ -646,6 +652,5 @@
          if ( !IsOkToClose(frame) )
          {
-            if ( !frame->CanClose() )
-               return false;
+               rc = frame->CanClose();
          }
          //else: had been asked before
@@ -655,16 +660,17 @@
       //      frame?
    }
+   }
 
+   if ( !rc )
+   {
+      // when we will try to close the next time, we shouldn't assume that
+      // these frames still don't mind being closed - may be the user will
+      // modify the compose view contents or something else changes
+      ((MAppBase *)this)->ResetFramesOkToClose();  // const_cast
 
-   // We assume that we can always close the toplevel frame if we make
-   // it until here. Attemps to close the toplevel frame will lead to
-   // this function being evaluated anyway. The frame itself does not
-   // do any tests.
-   wxMApp *self = (wxMApp *)this;
-   self->AddToFramesOkToClose(m_topLevelFrame);
-
-   self->m_CanClose = MAppBase::CanClose();
+      return false;
+   }
 
-   return m_CanClose;
+   return MAppBase::CanClose();
 }
 
@@ -679,12 +685,11 @@
 // do close the app by closing all frames
 void
-wxMApp::DoExit()
+wxMApp::OnClose()
 {
    // shut down MEvent handling
-   if(m_IdleTimer)
+   if ( m_IdleTimer )
    {
-      m_IdleTimer->Stop();
       delete m_IdleTimer;
-      m_IdleTimer = NULL; // paranoid
+      m_IdleTimer = NULL;
    }
 
@@ -692,4 +697,5 @@
    wxLog::FlushActive();
 
+#if 0
    // before deleting the frames, make sure that all dialogs which could be
    // still hanging around don't do it any more
@@ -714,4 +720,5 @@
       }
    }
+#endif // 0
 }
 

Index: wxMainFrame.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMainFrame.cpp,v
retrieving revision 1.147
retrieving revision 1.148
diff -b -u -2 -r1.147 -r1.148
--- wxMainFrame.cpp     28 Mar 2002 23:09:01 -0000      1.147
+++ wxMainFrame.cpp     15 Apr 2002 23:45:14 -0000      1.148
@@ -380,10 +380,15 @@
 wxMainFrame::CanClose() const
 {
+   // just in case it's still opened - may get in the way of our dialogs
+   CloseSplash();
+
    // closing the main frame will close the app so ask the other frames
    // whether it's ok to close them
-   bool rc = mApplication->CanClose();
-
-   if ( rc )
+   if ( !mApplication->CanClose() )
    {
+      // not confirmed by user
+      return false;
+   }
+
       // remember the last opened folder name
       if ( READ_APPCONFIG(MP_REOPENLASTFOLDER) )
@@ -395,7 +400,9 @@
       // make sure folder is closed before we close the window
       m_FolderView->SetFolder(NULL);
-   }
 
-   return rc;
+   // tell all the others that we're going away
+   mApplication->OnClose();
+
+   return true;
 }
 


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

Reply via email to