Tips close with the main window (#3305)

* tips close with main window

* null verification added
This commit is contained in:
David Szabo 2018-06-25 01:37:30 +02:00 committed by Zach H
parent 2354a6f89d
commit 87eb132af1
3 changed files with 19 additions and 9 deletions

View file

@ -22,7 +22,6 @@
#include "QtNetwork/QNetworkInterface" #include "QtNetwork/QNetworkInterface"
#include "carddatabase.h" #include "carddatabase.h"
#include "dlg_settings.h" #include "dlg_settings.h"
#include "dlg_tip_of_the_day.h"
#include "featureset.h" #include "featureset.h"
#include "logger.h" #include "logger.h"
#include "pixmapgenerator.h" #include "pixmapgenerator.h"
@ -142,11 +141,6 @@ int main(int argc, char *argv[])
ui.show(); ui.show();
qDebug("main(): ui.show() finished"); qDebug("main(): ui.show() finished");
DlgTipOfTheDay tip;
if (tip.successfulInit && settingsCache->getShowTipsOnStartup() && tip.newTipsAvailable) {
tip.show();
}
app.setAttribute(Qt::AA_UseHighDpiPixmaps); app.setAttribute(Qt::AA_UseHighDpiPixmaps);
app.exec(); app.exec();

View file

@ -317,9 +317,13 @@ void MainWindow::actAbout()
void MainWindow::actTips() void MainWindow::actTips()
{ {
DlgTipOfTheDay tip; if (tip != NULL) {
if (tip.successfulInit) { delete tip;
tip.exec(); tip = NULL;
}
tip = new DlgTipOfTheDay();
if (tip->successfulInit) {
tip->show();
} }
} }
@ -819,10 +823,19 @@ MainWindow::MainWindow(QWidget *parent)
qDebug() << "Spoilers Disabled"; qDebug() << "Spoilers Disabled";
QtConcurrent::run(db, &CardDatabase::loadCardDatabases); QtConcurrent::run(db, &CardDatabase::loadCardDatabases);
} }
tip = new DlgTipOfTheDay();
if (tip->successfulInit && settingsCache->getShowTipsOnStartup() && tip->newTipsAvailable) {
tip->show();
}
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
if (tip != NULL) {
delete tip;
tip = NULL;
}
if (trayIcon) { if (trayIcon) {
trayIcon->hide(); trayIcon->hide();
trayIcon->deleteLater(); trayIcon->deleteLater();
@ -885,6 +898,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
bClosingDown = false; bClosingDown = false;
return; return;
} }
tip->close();
event->accept(); event->accept();
settingsCache->setMainWindowGeometry(saveGeometry()); settingsCache->setMainWindowGeometry(saveGeometry());

View file

@ -41,6 +41,7 @@ class RemoteClient;
class ServerInfo_User; class ServerInfo_User;
class TabSupervisor; class TabSupervisor;
class WndSets; class WndSets;
class DlgTipOfTheDay;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
@ -133,6 +134,7 @@ private:
DlgViewLog *logviewDialog; DlgViewLog *logviewDialog;
DlgConnect *dlgConnect; DlgConnect *dlgConnect;
GameReplay *replay; GameReplay *replay;
DlgTipOfTheDay *tip;
public: public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);