[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1331: If Windows is restarting, then don't ask about delaying a se (in trunk/src: . gui)
Author: edmanm
Date: 2006-10-13 20:12:18 -0400 (Fri, 13 Oct 2006)
New Revision: 1331
Modified:
trunk/src/gui/mainwindow.cpp
trunk/src/gui/mainwindow.h
trunk/src/main.cpp
Log:
If Windows is restarting, then don't ask about delaying a server shut down;
just stop Tor and exit now so Windows doesn't yell at us.
Modified: trunk/src/gui/mainwindow.cpp
===================================================================
--- trunk/src/gui/mainwindow.cpp 2006-10-13 22:03:10 UTC (rev 1330)
+++ trunk/src/gui/mainwindow.cpp 2006-10-14 00:12:18 UTC (rev 1331)
@@ -108,6 +108,9 @@
connect(_torControl, SIGNAL(connectFailed(QString)),
this, SLOT(connectFailed(QString)));
+ /* Make sure we shut down when the operating system is restarting */
+ connect(vApp, SIGNAL(shutdown()), this, SLOT(shutdown()));
+
/* Put an icon in the system tray to indicate the status of Tor */
_trayIcon = new TrayIcon(IMG_TOR_STOPPED,
tr("Tor is Stopped"), _trayMenu);
@@ -134,9 +137,26 @@
delete _configDialog;
}
+/** Terminate the Tor process if it is being run under Vidalia, disconnect all
+ * TorControl signals, and exit Vidalia. */
+void
+MainWindow::shutdown()
+{
+ if (_torControl->isVidaliaRunningTor()) {
+ /* Kill our Tor process now */
+ _torControl->signal(TorSignal::Halt);
+ }
+
+ /* Disconnect all of the TorControl object's signals */
+ disconnect(_torControl, 0, 0, 0);
+
+ /* And then quit for real */
+ QCoreApplication::quit();
+}
+
/** Called when the application is closing, by selecting "Exit" from the tray
- * menu. This function disconnects the control socket and ends the Tor
- * process. */
+ * menu. If we're running a Tor server, then ask if we want to kill Tor now,
+ * or do a delayed shutdown. */
void
MainWindow::close()
{
@@ -151,20 +171,14 @@
&& !delayedShutdownStarted) {
if (delayServerShutdown()) {
/* Close when Tor stops */
- connect(_torControl, SIGNAL(stopped()), this, SLOT(close()));
+ connect(_torControl, SIGNAL(stopped()), this, SLOT(shutdown()));
delayedShutdownStarted = _torControl->signal(TorSignal::Shutdown);
return;
}
- /* Otherwise, just hill Tor now. Really. Die. */
- _torControl->signal(TorSignal::Halt);
}
}
-
- /* Disconnect all of the TorControl object's signals */
- disconnect(_torControl, 0, 0, 0);
-
- /* And then quit for real */
- QCoreApplication::quit();
+ /* Shut down Tor (if necessary) and exit Vidalia */
+ shutdown();
}
/** Create and bind actions to events. Setup for initial
Modified: trunk/src/gui/mainwindow.h
===================================================================
--- trunk/src/gui/mainwindow.h 2006-10-13 22:03:10 UTC (rev 1330)
+++ trunk/src/gui/mainwindow.h 2006-10-14 00:12:18 UTC (rev 1331)
@@ -51,10 +51,6 @@
/** Destructor. */
~MainWindow();
-public slots:
- /** Called when the user exits Vidalia. */
- void close();
-
private slots:
/** Called when the user selects "Start" from the menu. */
void start();
@@ -74,6 +70,11 @@
void disconnected();
/** Called when the user selects the "New Identity" action from the menu. */
void newIdentity();
+ /** Called when the user exits Vidalia. */
+ void close();
+ /** Terminate the Tor process if it is being run under Vidalia, disconnect
+ * all TorControl signals, and exit Vidalia. */
+ void shutdown();
private:
/** Create the actions on the tray menu or menubar */
Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp 2006-10-13 22:03:10 UTC (rev 1330)
+++ trunk/src/main.cpp 2006-10-14 00:12:18 UTC (rev 1331)
@@ -91,13 +91,9 @@
* Setting quitOnLastWindowClosed to false fixes this behavior. */
Vidalia::setQuitOnLastWindowClosed(false);
- /* Create an instance of the mainwindow and start the application */
+ /* Create an instance of the main window */
MainWindow mainWin;
- /* Handle the shutdown signal by closing the mainwindow, which closes
- * all the necessary child windows. */
- QObject::connect(&vidalia, SIGNAL(shutdown()), &mainWin, SLOT(close()));
-
/* Run Vidalia */
int ret = vidalia.exec();