From fadce387bbf04c21b5d4411e2389c9b0491356f4 Mon Sep 17 00:00:00 2001 From: palana Date: Tue, 16 Sep 2014 23:08:37 +0200 Subject: [PATCH] Add PostConfigureStreamButtons Deadlock free-er button updates --- Source/OBS.cpp | 9 +++++++++ Source/OBS.h | 2 ++ Source/WindowStuff.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/Source/OBS.cpp b/Source/OBS.cpp index 4b2f07b76..d27a8aedc 100644 --- a/Source/OBS.cpp +++ b/Source/OBS.cpp @@ -1382,12 +1382,21 @@ void OBS::RefreshStreamButtons(bool disable) void OBS::ConfigureStreamButtons() { if (bShuttingDown) return; + + if (GetWindowThreadProcessId(hwndMain, nullptr) != GetCurrentThreadId()) + return PostConfigureStreamButtons(); + RefreshStreamButtons(); SetWindowText(GetDlgItem(hwndMain, ID_STARTSTOP), bStreaming ? Str("MainWindow.StopStream") : Str("MainWindow.StartStream")); SetWindowText(GetDlgItem(hwndMain, ID_TOGGLERECORDING), bRecording ? Str("MainWindow.StopRecording") : Str("MainWindow.StartRecording")); SetWindowText(GetDlgItem(hwndMain, ID_TESTSTREAM), bTestStream ? Str("MainWindow.StopTest") : Str("MainWindow.TestStream")); } +void OBS::PostConfigureStreamButtons() +{ + if (hwndMain) PostMessage(hwndMain, OBS_CONFIGURE_STREAM_BUTTONS, 0, 0); +} + void OBS::ReloadSceneCollection() { HWND hwndTemp; diff --git a/Source/OBS.h b/Source/OBS.h index 5edf0e027..fbcfcf054 100644 --- a/Source/OBS.h +++ b/Source/OBS.h @@ -423,6 +423,7 @@ enum OBS_UPDATESTATUSBAR, OBS_NOTIFICATIONAREA, OBS_NETWORK_FAILED, + OBS_CONFIGURE_STREAM_BUTTONS, }; //---------------------------- @@ -1099,6 +1100,7 @@ class OBS void RefreshStreamButtons(bool disable=false); void ConfigureStreamButtons(); + void PostConfigureStreamButtons(); void ReloadIniSettings(); diff --git a/Source/WindowStuff.cpp b/Source/WindowStuff.cpp index 82aa38a46..88cf1c5c3 100644 --- a/Source/WindowStuff.cpp +++ b/Source/WindowStuff.cpp @@ -4182,6 +4182,10 @@ LRESULT CALLBACK OBS::OBSProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa App->SetStatusBarData(); break; + case OBS_CONFIGURE_STREAM_BUTTONS: + App->ConfigureStreamButtons(); + break; + case OBS_NOTIFICATIONAREA: // the point is to only perform the show/hide (minimize) or the menu creation if no modal dialogs are opened // if a modal dialog is topmost, then simply focus it