1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-16 02:35:27 +01:00

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

View File

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