From ddeb2236aebb165af8f75c117a68ad1848e0b4e3 Mon Sep 17 00:00:00 2001 From: Christian Aguilera Date: Sat, 15 Aug 2020 00:28:19 +0100 Subject: [PATCH] Removed RunOnObject() usage to prevent deadlock on exiting the NetPlay Session Browser dialog. --- .../Core/DolphinQt/NetPlay/NetPlayBrowser.cpp | 35 +++++++++++-------- .../Core/DolphinQt/NetPlay/NetPlayBrowser.h | 7 ++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp index f5cb95eaa9..010dba6ab4 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp @@ -26,7 +26,6 @@ #include "Core/ConfigManager.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" -#include "DolphinQt/QtUtils/RunOnObject.h" #include "DolphinQt/Settings.h" NetPlayBrowser::NetPlayBrowser(QWidget* parent) : QDialog(parent) @@ -148,6 +147,11 @@ void NetPlayBrowser::ConnectWidgets() connect(m_table_widget, &QTableWidget::itemSelectionChanged, this, &NetPlayBrowser::OnSelectionChanged); connect(m_table_widget, &QTableWidget::itemDoubleClicked, this, &NetPlayBrowser::accept); + + connect(this, &NetPlayBrowser::UpdateStatusRequested, this, + &NetPlayBrowser::OnUpdateStatusRequested, Qt::QueuedConnection); + connect(this, &NetPlayBrowser::UpdateListRequested, this, &NetPlayBrowser::OnUpdateListRequested, + Qt::QueuedConnection); } void NetPlayBrowser::Refresh() @@ -191,10 +195,7 @@ void NetPlayBrowser::RefreshLoop() lock.unlock(); - RunOnObject(this, [this] { - m_status_label->setText(tr("Refreshing...")); - return nullptr; - }); + emit UpdateStatusRequested(tr("Refreshing...")); NetPlayIndex client; @@ -202,19 +203,12 @@ void NetPlayBrowser::RefreshLoop() if (entries) { - RunOnObject(this, [this, &entries] { - m_sessions = *entries; - UpdateList(); - return nullptr; - }); + emit UpdateListRequested(std::move(*entries)); } else { - RunOnObject(this, [this, &client] { - m_status_label->setText(tr("Error obtaining session list: %1") - .arg(QString::fromStdString(client.GetLastError()))); - return nullptr; - }); + emit UpdateStatusRequested(tr("Error obtaining session list: %1") + .arg(QString::fromStdString(client.GetLastError()))); } } } @@ -277,6 +271,17 @@ void NetPlayBrowser::OnSelectionChanged() ->setEnabled(!m_table_widget->selectedItems().isEmpty()); } +void NetPlayBrowser::OnUpdateStatusRequested(const QString& status) +{ + m_status_label->setText(status); +} + +void NetPlayBrowser::OnUpdateListRequested(std::vector sessions) +{ + m_sessions = std::move(sessions); + UpdateList(); +} + void NetPlayBrowser::accept() { if (m_table_widget->selectedItems().isEmpty()) diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h index 3a7648be51..86dc0f5cce 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h +++ b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h @@ -35,6 +35,8 @@ public: void accept() override; signals: void Join(); + void UpdateStatusRequested(const QString& status); + void UpdateListRequested(std::vector sessions); private: void CreateWidgets(); @@ -46,6 +48,9 @@ private: void OnSelectionChanged(); + void OnUpdateStatusRequested(const QString& status); + void OnUpdateListRequested(std::vector sessions); + void SaveSettings() const; void RestoreSettings(); @@ -71,3 +76,5 @@ private: Common::Flag m_refresh_run; Common::Event m_refresh_event; }; + +Q_DECLARE_METATYPE(std::vector)