From 1b735084a41eac2182c7a7e99b348319ac630cd3 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 7 Jul 2025 17:44:47 +0600 Subject: [PATCH] Always load "opengl32.dll" from application directory if it exists --- src/qt/qt_main.cpp | 12 ++++++++++++ src/qt/qt_platform.cpp | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index eb7d6ac44..da57bcf80 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -102,6 +102,8 @@ bool cpu_thread_running = false; void qt_set_sequence_auto_mnemonic(bool b); #ifdef Q_OS_WINDOWS +bool acp_utf8 = false; + static void keyboard_getkeymap() { @@ -515,6 +517,13 @@ extern bool windows_is_light_theme(); int main(int argc, char *argv[]) { +#ifdef Q_OS_WINDOWS + /* Check if Windows supports UTF-8 */ + if (GetACP() == CP_UTF8) + acp_utf8 = 1; + else + acp_utf8 = 0; +#endif #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); @@ -530,6 +539,9 @@ main(int argc, char *argv[]) #ifdef Q_OS_WINDOWS Q_INIT_RESOURCE(darkstyle); + if (QFile(QApplication::applicationDirPath() + "/opengl32.dll").exists()) { + qputenv("QT_OPENGL_DLL", QFileInfo(QApplication::applicationDirPath() + "/opengl32.dll").absoluteFilePath().toUtf8()); + } QApplication::setAttribute(Qt::AA_NativeWindows); if (!windows_is_light_theme()) { diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 8677a6a91..a2c0bc410 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -177,14 +177,28 @@ do_stop(void) #endif } +extern bool acp_utf8; void plat_get_exe_name(char *s, int size) { +#ifdef Q_OS_WINDOWS + wchar_t *temp; + + if (acp_utf8) + GetModuleFileNameA(NULL, s, size); + else { + temp = (wchar_t*)calloc(size, sizeof(wchar_t)); + GetModuleFileNameW(NULL, temp, size); + c16stombs(s, (uint16_t*)temp, size); + free(temp); + } +#else QByteArray exepath_temp = QCoreApplication::applicationDirPath().toLocal8Bit(); memcpy(s, exepath_temp.data(), std::min((qsizetype) exepath_temp.size(), (qsizetype) size)); path_slash(s); +#endif } uint32_t