From 604f3b450099dabee5ce95453fe2b6d3ef14d90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Mar 2023 14:25:20 +0100 Subject: [PATCH] Try to fix Qt. Still broken due to threading issue. --- Qt/QtMain.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 65498db322..2e2d962c13 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -34,7 +34,7 @@ #endif #include "Common/System/NativeApp.h" -#include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/Math/math_util.h" #include "Common/Profiler/Profiler.h" @@ -273,7 +273,24 @@ void System_Notify(SystemNotification notification) { } } -bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2) { return false; } +bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2) { + switch (type) { + case SystemRequestType::INPUT_TEXT_MODAL: + { + // NOTE: This doesn't actually work, we're on the wrong thread! + // Was broken even previously to the conversion to System_MakeRequest. + QString title = QString::fromStdString(param1); + QString defaultValue = QString::fromStdString(param2); + QString text = emugl->InputBoxGetQString(title, defaultValue); + if (text.isEmpty()) { + g_requestManager.PostSystemFailure(requestId); + } else { + g_requestManager.PostSystemSuccess(requestId, text.toStdString().c_str()); + } + break; + } + } +} void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { @@ -307,15 +324,6 @@ void System_Toast(const char *text) {} void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } -void System_InputBoxGetString(const std::string &title, const std::string &defaultValue, std::function cb) { - QString text = emugl->InputBoxGetQString(QString::fromStdString(title), QString::fromStdString(defaultValue)); - if (text.isEmpty()) { - NativeInputBoxReceived(cb, false, ""); - } else { - NativeInputBoxReceived(cb, true, text.toStdString()); - } -} - void System_Vibrate(int length_ms) { if (length_ms == -1 || length_ms == -3) length_ms = 50;