[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1382: If the user selects "Stop" and is running a server and opts (trunk/src/gui)



Author: edmanm
Date: 2006-10-23 03:15:38 -0400 (Mon, 23 Oct 2006)
New Revision: 1382

Modified:
   trunk/src/gui/mainwindow.cpp
   trunk/src/gui/mainwindow.h
Log:
If the user selects "Stop" and is running a server and opts for a delayed
shutdown and then selects "Quit," we should exit immediately instead of
prompting the user again. Similarly, if the user selects "Quit" and is running
a server and opts for a delayed shutdown and then selects "Stop," we
should stop Tor without prompting and then continue with the "Quit"
immediately.


Modified: trunk/src/gui/mainwindow.cpp
===================================================================
--- trunk/src/gui/mainwindow.cpp	2006-10-23 07:09:08 UTC (rev 1381)
+++ trunk/src/gui/mainwindow.cpp	2006-10-23 07:15:38 UTC (rev 1382)
@@ -144,7 +144,7 @@
 {
   if (_torControl->isVidaliaRunningTor()) {
     /* Kill our Tor process now */ 
-    _torControl->signal(TorSignal::Halt);
+    _torControl->stop();
   }
 
   /* Disconnect all of the TorControl object's signals */
@@ -160,19 +160,18 @@
 void
 MainWindow::close()
 {
-  static bool delayedShutdownStarted = false;
-  
   if (_torControl->isVidaliaRunningTor()) {
     /* If we're running a server currently, ask if we want to do a delayed
      * shutdown. If we do, then close Vidalia only when Tor stops. Otherwise,
      * kill Tor and bail now. */
     ServerSettings settings(_torControl);
     if (_torControl->isConnected() && settings.isServerEnabled() 
-                                   && !delayedShutdownStarted) {
+                                   && !_delayedShutdownStarted) {
       if (delayServerShutdown()) {
         /* Close when Tor stops */
         connect(_torControl, SIGNAL(stopped()), this, SLOT(shutdown()));
-        delayedShutdownStarted = _torControl->signal(TorSignal::Shutdown);
+        _delayedShutdownStarted = _torControl->signal(TorSignal::Shutdown);
+        _trayIcon->update(IMG_TOR_STOPPING, tr("Tor is stopping"));
         return;
       }
     }
@@ -351,6 +350,8 @@
   /* Now that Tor is running, we want to know if it dies when we didn't want
    * it to. */
   _isIntentionalExit = false;
+  /* We haven't started a delayed shutdown yet. */
+  _delayedShutdownStarted = false;
   /* Set correct tray icon and tooltip */
   _trayIcon->update(IMG_TOR_STARTING, tr("Tor is starting"));
   /* Set menu actions appropriately */
@@ -408,24 +409,22 @@
 void 
 MainWindow::stop()
 {
-  static bool delayedShutdownStarted = false;
   ServerSettings server(_torControl);
   QString errmsg;
   bool shutdown;
   
   /* If we're running a server, give users the option of terminating
    * gracefully so clients have time to find new servers. */
-  if (server.isServerEnabled() && !delayedShutdownStarted
+  if (server.isServerEnabled() && !_delayedShutdownStarted
                                && delayServerShutdown()) {
     /* Delayed server shutdown was started successfully. */
     shutdown = _torControl->signal(TorSignal::Shutdown);
-    delayedShutdownStarted = shutdown;
+    _delayedShutdownStarted = shutdown;
   } else {
     /* Terminate the Tor process immediately */
     _isIntentionalExit = true;
     if ((shutdown = _torControl->stop(&errmsg)) == true) {
       _stopAct->setEnabled(false);
-      delayedShutdownStarted = false;
     }
   }
 
@@ -456,7 +455,6 @@
 {
   /* Set correct tray icon and tooltip */
   _trayIcon->update(IMG_TOR_STOPPED, tr("Tor is stopped"));
-
   /* Set menu actions appropriately */
   _startAct->setEnabled(true);
 

Modified: trunk/src/gui/mainwindow.h
===================================================================
--- trunk/src/gui/mainwindow.h	2006-10-23 07:09:08 UTC (rev 1381)
+++ trunk/src/gui/mainwindow.h	2006-10-23 07:15:38 UTC (rev 1382)
@@ -88,6 +88,8 @@
   
   /* Used to determine if the Tor process exiting was intentional or not */
   bool _isIntentionalExit;
+  /** Tracks whether we started a delayed server shutdown. */
+  bool _delayedShutdownStarted;
   
   /** An AboutDialog object, used to display version information. */
   AboutDialog* _aboutDialog;