diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index a55b5b94b2..ce710b6ce0 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -877,7 +877,7 @@ void MainWindow::OnImportNANDBackup() .arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000)); }); }); - QueueOnObject(dialog, [dialog] { dialog->close(); }); + QueueOnObject(dialog, &QProgressDialog::close); }); dialog->exec(); diff --git a/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp index fed75b2eb1..77a17486b5 100644 --- a/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp @@ -405,7 +405,7 @@ void NetPlayDialog::StopGame() void NetPlayDialog::Update() { - QueueOnObject(this, [this] { UpdateGUI(); }); + QueueOnObject(this, &NetPlayDialog::UpdateGUI); } void NetPlayDialog::DisplayMessage(const QString& msg, const std::string& color, int duration) @@ -524,7 +524,7 @@ void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error) bool NetPlayDialog::IsRecording() { - return RunOnObject(this, [this] { return m_record_input_box->isChecked(); }); + return RunOnObject(m_record_input_box, &QCheckBox::isChecked); } std::string NetPlayDialog::FindGame(const std::string& game) diff --git a/Source/Core/DolphinQt2/QtUtils/QueueOnObject.h b/Source/Core/DolphinQt2/QtUtils/QueueOnObject.h index 6110bccb79..a50e757d55 100644 --- a/Source/Core/DolphinQt2/QtUtils/QueueOnObject.h +++ b/Source/Core/DolphinQt2/QtUtils/QueueOnObject.h @@ -12,8 +12,8 @@ // arbitrary code from non-GUI threads. For more information, see: // https://stackoverflow.com/questions/21646467/ -template -static void QueueOnObject(QObject* obj, F&& func) +template +static void QueueOnObject(T* obj, F&& func) { QObject src; QObject::connect(&src, &QObject::destroyed, obj, std::forward(func), Qt::QueuedConnection); diff --git a/Source/Core/DolphinQt2/QtUtils/RunOnObject.h b/Source/Core/DolphinQt2/QtUtils/RunOnObject.h index d1ebcd22cc..bd0b2ca556 100644 --- a/Source/Core/DolphinQt2/QtUtils/RunOnObject.h +++ b/Source/Core/DolphinQt2/QtUtils/RunOnObject.h @@ -33,3 +33,9 @@ auto RunOnObject(QObject* object, F&& functor) event.Wait(); return result; } + +template +auto RunOnObject(Receiver* obj, Type Base::*func) +{ + return RunOnObject(obj, [obj, func] { return (obj->*func)(); }); +}