From 98d5e27a8c6a450c84338d7c8944ca10fb9af535 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 30 Jan 2021 21:52:17 +0100 Subject: [PATCH] Remove use of NewClosure for playback resume --- src/core/mainwindow.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index faef6a1d5..3646aa64d 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ #include #include "core/logging.h" -#include "core/closure.h" #include "core/networkaccessmanager.h" #include "mainwindow.h" @@ -1424,10 +1424,18 @@ void MainWindow::ResumePlayback() { // Set active to current to resume playback on correct playlist. app_->playlist_manager()->SetActiveToCurrent(); if (playback_state == Engine::Paused) { - NewClosure(app_->player(), SIGNAL(Playing()), app_->player(), SLOT(PlayPause())); + std::shared_ptr connection = std::make_shared(); + *connection = QObject::connect(app_->player(), &Player::Playing, app_->player(), [this, connection]() { + QObject::disconnect(*connection); + app_->player()->PlayPause(); + }); } // Seek after we got song length. - NewClosure(track_position_timer_, SIGNAL(timeout()), this, SLOT(ResumePlaybackSeek(int)), playback_position); + std::shared_ptr connection = std::make_shared(); + *connection = QObject::connect(track_position_timer_, &QTimer::timeout, this, [this, connection, playback_position]() { + QObject::disconnect(*connection); + ResumePlaybackSeek(playback_position); + }); app_->player()->Play(); }