From e0399e732dbb6230a4c5256d2c1718a106c7dde9 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Fri, 17 Feb 2017 17:16:43 +0100 Subject: [PATCH] Fix for freeze on scene collection change --- advanced-scene-switcher-win.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/advanced-scene-switcher-win.cpp b/advanced-scene-switcher-win.cpp index 31d2bf6f..8ffa1d7e 100644 --- a/advanced-scene-switcher-win.cpp +++ b/advanced-scene-switcher-win.cpp @@ -61,7 +61,16 @@ void GetWindowList(vector& windows) void GetCurrentWindowTitle(string& title) { HWND window = GetForegroundWindow(); - //DWORD id; + DWORD id; + GetWindowThreadProcessId(window, &id); + /*GetWindowText will freeze if the control it is reading was created in another thread. + It does not directly read the control.Instead, + it waits for the thread that created the control to process a WM_GETTEXT message. + So if that thread is frozen in a WaitFor... call you have a deadlock.*/ + if (id == GetCurrentProcessId()) { + title = ""; + return; + } GetWindowTitle(window, title); } @@ -155,4 +164,4 @@ int getTime() int secondsSinceLastInput() { return (getTime() - getLastInputTime()) / 1000; -} \ No newline at end of file +}