From 268b424843c859d5d063dfa2da8b3edd7670cddc Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 21 May 2018 15:27:12 -0700 Subject: QtUtils/RunOnObject: Make safe under object destruction Co-Authored-By: cancel --- Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp') diff --git a/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp index 8dcd4df9db..e6d7c29800 100644 --- a/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp @@ -580,12 +580,15 @@ void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error) bool NetPlayDialog::IsRecording() { - return RunOnObject(m_record_input_box, &QCheckBox::isChecked); + std::optional is_recording = RunOnObject(m_record_input_box, &QCheckBox::isChecked); + if (is_recording) + return *is_recording; + return false; } std::string NetPlayDialog::FindGame(const std::string& game) { - return RunOnObject(this, [this, game] { + std::optional path = RunOnObject(this, [this, game] { for (int i = 0; i < m_game_list_model->rowCount(QModelIndex()); i++) { if (m_game_list_model->GetUniqueIdentifier(i).toStdString() == game) @@ -593,6 +596,9 @@ std::string NetPlayDialog::FindGame(const std::string& game) } return std::string(""); }); + if (path) + return *path; + return std::string(""); } void NetPlayDialog::ShowMD5Dialog(const std::string& file_identifier) -- cgit v1.2.3