diff --git a/GUI/extenwindow.cpp b/GUI/extenwindow.cpp index 1f3c4a3..180dae0 100644 --- a/GUI/extenwindow.cpp +++ b/GUI/extenwindow.cpp @@ -36,7 +36,7 @@ namespace { if (HMODULE module = LoadLibraryW(S(extenName).c_str())) { - if (auto callback = (decltype(Extension::callback))GetProcAddress(LoadLibraryOnce(S(extenName)), "OnNewSentence")) + if (auto callback = (decltype(Extension::callback))GetProcAddress(module, "OnNewSentence")) { std::scoped_lock writeLock(extenMutex); extensions.push_back({ S(extenName), callback }); diff --git a/GUI/extenwindow.h b/GUI/extenwindow.h index a5a3f5f..67c8c38 100644 --- a/GUI/extenwindow.h +++ b/GUI/extenwindow.h @@ -34,5 +34,3 @@ private: Ui::ExtenWindow* ui; }; - -inline HMODULE LoadLibraryOnce(std::wstring fileName) { if (HMODULE module = GetModuleHandleW(fileName.c_str())) return module; return LoadLibraryW(fileName.c_str()); } diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index c1e72b7..203fffc 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -309,7 +309,7 @@ void MainWindow::LaunchProcess() PROCESS_INFORMATION info = {}; if (!x64 && QMessageBox::question(this, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes) { - if (HMODULE localeEmulator = LoadLibraryOnce(L"LoaderDll")) + if (HMODULE localeEmulator = LoadLibraryW(L"LoaderDll")) { // see https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs#L252 struct diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index ce998a0..198b93b 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -19,8 +19,6 @@ private: inline static constexpr auto HOOK_SAVE_FILE = u8"SavedHooks.txt"; inline static constexpr auto GAME_SAVE_FILE = u8"SavedGames.txt"; - inline static thread_local bool ok = false; - void closeEvent(QCloseEvent*) override; void ProcessConnected(DWORD processId); void ProcessDisconnected(DWORD processId); diff --git a/extensions/extrawindow.cpp b/extensions/extrawindow.cpp index 5a26a2c..fcaa4a1 100644 --- a/extensions/extrawindow.cpp +++ b/extensions/extrawindow.cpp @@ -59,7 +59,6 @@ protected: private: void RequestFont() { - bool ok; if (QFont font = QFontDialog::getFont(&ok, ui.display->font(), this, FONT); ok) { settings.setValue(FONT, font.toString()); diff --git a/include/qtcommon.h b/include/qtcommon.h index 03a28a3..cf4a02c 100644 --- a/include/qtcommon.h +++ b/include/qtcommon.h @@ -20,6 +20,8 @@ #include #include +static thread_local bool ok; + struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } }; inline std::wstring S(const QString& S) { return { S.toStdWString() }; } inline QString S(const std::string& S) { return QString::fromStdString(S); }