Windows: Lock when updating the window title

This commit is contained in:
Henrik Rydgård committed 2025-03-06 14:24:40 +01:00
1 parent c36375d6c8
commit 3ab625a0fa
4 files changed
+19 -6

No files matched your search

+12 -3
View File
@@ -113,7 +113,8 @@ struct VerySleepy_AddrInfo {
wchar_t name[256];
};
static std::wstring windowTitle;
static std::mutex g_windowTitleLock;
static std::wstring g_windowTitle;
#define TIMER_CURSORUPDATE 1
#define TIMER_CURSORMOVEUPDATE 2
@@ -469,7 +470,11 @@ namespace MainWindow
}
void UpdateWindowTitle() {
std::wstring title = windowTitle;
std::wstring title;
{
std::lock_guard<std::mutex> lock(g_windowTitleLock);
title = g_windowTitle;
}
if (PPSSPP_ID >= 1 && GetInstancePeerCount() > 1) {
title.append(ConvertUTF8ToWString(StringFromFormat(" (instance: %d)", (int)PPSSPP_ID)));
}
@@ -477,7 +482,11 @@ namespace MainWindow
}
void SetWindowTitle(const wchar_t *title) {
windowTitle = title;
{
std::lock_guard<std::mutex> lock(g_windowTitleLock);
g_windowTitle = title;
}
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
}
BOOL Show(HINSTANCE hInstance) {