mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
Qt: Fix use-after-free race condition in achievement login dialog
This commit is contained in:
parent
a46ee17537
commit
c79e6ecc2c
@ -9,6 +9,7 @@
|
||||
|
||||
#include "common/Error.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
AchievementLoginDialog::AchievementLoginDialog(QWidget* parent, Achievements::LoginRequestReason reason)
|
||||
@ -44,11 +45,18 @@ void AchievementLoginDialog::loginClicked()
|
||||
m_ui.status->setText(tr("Logging in..."));
|
||||
enableUI(false);
|
||||
|
||||
Host::RunOnCPUThread([this, username = std::move(username), password = std::move(password)]() {
|
||||
const QPointer<AchievementLoginDialog> dialog(this);
|
||||
Host::RunOnCPUThread([dialog, username = std::move(username), password = std::move(password)]() {
|
||||
Error error;
|
||||
const bool result = Achievements::Login(username.c_str(), password.c_str(), &error);
|
||||
const QString message = QString::fromStdString(error.GetDescription());
|
||||
QMetaObject::invokeMethod(this, "processLoginResult", Qt::QueuedConnection, Q_ARG(bool, result), Q_ARG(const QString&, message));
|
||||
|
||||
QtHost::RunOnUIThread([dialog, result, message = std::move(message)]() {
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
dialog->processLoginResult(result, message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user