This commit is contained in:
Akash Mozumdar 2019-09-16 17:14:59 -04:00
parent 46c4f163ba
commit f9e1e61d51
6 changed files with 4 additions and 7 deletions

View File

@ -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 });

View File

@ -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()); }

View File

@ -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

View File

@ -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);

View File

@ -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());

View File

@ -20,6 +20,8 @@
#include <QMessageBox>
#include <QInputDialog>
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); }