Merge pull request #1010 from poixen/server_shutdown_warnings

Updated server shutdown timer logic
This commit is contained in:
woogerboy21 2015-04-23 10:59:32 -04:00
commit 924dd174e3
4 changed files with 34 additions and 21 deletions

View file

@ -86,7 +86,13 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event)
{
QMessageBox::information(this, tr("Scheduled server shutdown"), tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason())));
if (serverShutdownMessageBox)
serverShutdownMessageBox->close();
serverShutdownMessageBox = new QMessageBox(this);
serverShutdownMessageBox->setAttribute(Qt::WA_DeleteOnClose);
serverShutdownMessageBox->setInformativeText(tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason())));
serverShutdownMessageBox->setText(tr("Scheduled server shutdown"));
serverShutdownMessageBox->exec();
}
void MainWindow::statusChanged(ClientStatus _status)

View file

@ -31,6 +31,7 @@ class LocalClient;
class LocalServer;
class ServerInfo_User;
class QThread;
class QMessageBox;
class MainWindow : public QMainWindow {
Q_OBJECT
@ -86,6 +87,8 @@ private:
LocalServer *localServer;
bool bHasActivated;
QMessageBox *serverShutdownMessageBox;
public:
MainWindow(QWidget *parent = 0);
~MainWindow();

View file

@ -126,7 +126,7 @@ void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor)
}
Servatrice::Servatrice(QObject *parent)
: Server(true, parent), uptime(0), shutdownTimer(0)
: Server(true, parent), uptime(0), shutdownTimer(0), isFirstShutdownMessage(true)
{
qRegisterMetaType<QSqlDatabase>("QSqlDatabase");
}
@ -485,6 +485,8 @@ void Servatrice::shutdownTimeout()
{
--shutdownMinutes;
if (shutdownMinutes <= 5 || isFirstShutdownMessage || shutdownMinutes % 10 == 0) {
isFirstShutdownMessage = false;
SessionEvent *se;
if (shutdownMinutes) {
Event_ServerShutdown event;
@ -505,6 +507,7 @@ void Servatrice::shutdownTimeout()
if (!shutdownMinutes)
deleteLater();
}
}
bool Servatrice::islConnectionExists(int serverId) const

View file

@ -120,6 +120,7 @@ private:
QString shutdownReason;
int shutdownMinutes;
QTimer *shutdownTimer;
bool isFirstShutdownMessage;
mutable QMutex serverListMutex;
QList<ServerProperties> serverList;