Fix remembering hidden state

Prevent SetHiddenInTray() or Exit() from being called again after
qApp->quit() in MainWindow::closeEvent()
This commit is contained in:
Jonas Kvinge
2021-04-16 18:27:24 +02:00
parent c855108b94
commit ae2ca175d3
2 changed files with 11 additions and 5 deletions

View File

@@ -315,6 +315,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
was_maximized_(true), was_maximized_(true),
was_minimized_(false), was_minimized_(false),
hidden_(false), hidden_(false),
exit_(false),
exit_count_(0), exit_count_(0),
delete_files_(false) delete_files_(false)
{ {
@@ -1171,6 +1172,7 @@ void MainWindow::Exit() {
if (exit_count_ > 1) { if (exit_count_ > 1) {
qApp->quit(); qApp->quit();
exit_ = true;
} }
else { else {
if (app_->player()->engine()->is_fadeout_enabled()) { if (app_->player()->engine()->is_fadeout_enabled()) {
@@ -1192,6 +1194,7 @@ void MainWindow::DoExit() {
QObject::connect(app_, &Application::ExitFinished, this, &MainWindow::ExitFinished); QObject::connect(app_, &Application::ExitFinished, this, &MainWindow::ExitFinished);
app_->Exit(); app_->Exit();
exit_ = true;
} }
@@ -1563,11 +1566,13 @@ void MainWindow::showEvent(QShowEvent *e) {
void MainWindow::closeEvent(QCloseEvent *e) { void MainWindow::closeEvent(QCloseEvent *e) {
if (!hidden_ && keep_running_ && e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable()) { if (!exit_) {
SetHiddenInTray(true); if (!hidden_ && keep_running_ && e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable()) {
} SetHiddenInTray(true);
else { }
Exit(); else {
Exit();
}
} }
QMainWindow::closeEvent(e); QMainWindow::closeEvent(e);

View File

@@ -390,6 +390,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
Song song_; Song song_;
Song song_playing_; Song song_playing_;
AlbumCoverImageResult album_cover_; AlbumCoverImageResult album_cover_;
bool exit_;
int exit_count_; int exit_count_;
bool delete_files_; bool delete_files_;