Bugfix for resume playback on start

This fixes issue #5365.

Because of the asynchronous loading of playlists introduced by
09e83935, the resume playback on startup logic finds the active
playlist as empty, because it is not restored yet. By attaching
the playback resume to the RestoreFinish signal, the playback
will be triggered as soon as the playlist is restored. It may be
possible (but unlikely) that the playlist will already be restored
before we wait for the signal, and playback won't be resumed.

Signed-off-by: Marko Hauptvogel <marko.hauptvogel@googlemail.com>
This commit is contained in:
Marko Hauptvogel 2016-12-22 06:55:37 +01:00 committed by John Maguire
parent 00c96f7334
commit 57d00394ee
1 changed files with 5 additions and 1 deletions

View File

@ -1295,12 +1295,16 @@ void MainWindow::LoadPlaybackStatus() {
return;
}
QTimer::singleShot(100, this, SLOT(ResumePlayback()));
connect(app_->playlist_manager()->active(), SIGNAL(RestoreFinished()),
SLOT(ResumePlayback()));
}
void MainWindow::ResumePlayback() {
qLog(Debug) << "Resuming playback";
disconnect(app_->playlist_manager()->active(), SIGNAL(RestoreFinished()),
this, SLOT(ResumePlayback()));
if (saved_playback_state_ == Engine::Paused) {
NewClosure(app_->player(), SIGNAL(Playing()), app_->player(),
SLOT(PlayPause()));