Merge pull request #1106 from ctrlaltca/fix_1105

Fix crash on server shutdown; fix #1105
This commit is contained in:
ctrlaltca 2015-05-23 18:26:13 +02:00
commit 411fc38337
2 changed files with 7 additions and 11 deletions

View file

@ -86,13 +86,11 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event) void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event)
{ {
if (serverShutdownMessageBox) 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->close(); serverShutdownMessageBox.setIconPixmap(QPixmap(":/resources/appicon.svg").scaled(64, 64));
serverShutdownMessageBox = new QMessageBox(this); serverShutdownMessageBox.setText(tr("Scheduled server shutdown"));
serverShutdownMessageBox->setAttribute(Qt::WA_DeleteOnClose); serverShutdownMessageBox.setWindowModality(Qt::ApplicationModal);
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.setVisible(true);
serverShutdownMessageBox->setText(tr("Scheduled server shutdown"));
serverShutdownMessageBox->exec();
} }
void MainWindow::statusChanged(ClientStatus _status) void MainWindow::statusChanged(ClientStatus _status)
@ -436,8 +434,6 @@ MainWindow::MainWindow(QWidget *parent)
createTrayActions(); createTrayActions();
createTrayIcon(); createTrayIcon();
} }
serverShutdownMessageBox = 0;
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()

View file

@ -23,6 +23,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QProcess> #include <QProcess>
#include <QMessageBox>
#include "abstractclient.h" #include "abstractclient.h"
#include "pb/response.pb.h" #include "pb/response.pb.h"
@ -32,7 +33,6 @@ class LocalClient;
class LocalServer; class LocalServer;
class ServerInfo_User; class ServerInfo_User;
class QThread; class QThread;
class QMessageBox;
class MainWindow : public QMainWindow { class MainWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
@ -95,7 +95,7 @@ private:
LocalServer *localServer; LocalServer *localServer;
bool bHasActivated; bool bHasActivated;
QMessageBox *serverShutdownMessageBox; QMessageBox serverShutdownMessageBox;
QProcess * cardUpdateProcess; QProcess * cardUpdateProcess;
public: public:
MainWindow(QWidget *parent = 0); MainWindow(QWidget *parent = 0);