OTHER: Rework the 'Quit server on close' option

Quit server on close is now implemented in a cleaner and easier
understandable way. It also doesn't impact the application shutdown time
any more.
This commit is contained in:
Thomas Frauendorfer 2008-10-16 19:02:09 +02:00
parent 5e8d83ca8e
commit 11b7e5e6e7
4 changed files with 30 additions and 32 deletions

View file

@ -29,44 +29,38 @@
Application::Application (int &argc, char **argv) : QApplication (argc, argv)
{
m_want_quit = false;
//TODO: Change to XClient sometime later
XMMSHandler &client = XMMSHandler::getInstance ();
connect (this, SIGNAL (aboutToQuit ()),
this, SLOT (cleanupHandler ()));
connect (&client, SIGNAL(disconnected(XClient *)),
this, SLOT(handleDisconnected ()));
}
void
Application::quit ()
Application::cleanupHandler ()
{
// quit for real in case something went wrong earlier
if (m_want_quit)
QApplication::quit ();
QSettings s;
if (s.value ("promoe/quitonclose", false).toBool ()) {
m_want_quit = true;
if (!XMMSHandler::getInstance ().quit ()) {
QApplication::quit ();
}
} else {
QApplication::quit ();
}
if (s.value ("promoe/quitonclose", false).toBool ())
XMMSHandler::getInstance ().shutdownServer ();
}
void
Application::handleDisconnected ()
{
if (!m_want_quit) {
// if the Application is about to quit, we no longer need to handle
// disconnects
if (closingDown ())
return;
// TODO: enable reconnect
QMessageBox::critical( NULL, "xmms2 daemon disconnected",
"The xmms2 deamon has disconnected\n"
"This could be because the server crashed\n"
"or because another client has shut down the sever.",
"Quit Promoe");
}
QMessageBox::critical( NULL, "xmms2 daemon disconnected",
"The xmms2 deamon has disconnected\n"
"This could be because the server crashed\n"
"or because another client has shut down the sever.",
"Quit Promoe");
QApplication::quit ();
}

View file

@ -29,10 +29,6 @@ class Application : public QApplication
Application (int &argc, char **argv);
public slots:
void quit ();
void cleanupHandler ();
void handleDisconnected ();
private:
bool m_want_quit;
};