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

View file

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

View file

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