Skip to content

Commit

Permalink
Add PostConfigureStreamButtons
Browse files Browse the repository at this point in the history
Deadlock free-er button updates
  • Loading branch information
palana committed Sep 24, 2014
1 parent b998dd5 commit fadce38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/OBS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Source/OBS.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ enum
OBS_UPDATESTATUSBAR,
OBS_NOTIFICATIONAREA,
OBS_NETWORK_FAILED,
OBS_CONFIGURE_STREAM_BUTTONS,
};

//----------------------------
Expand Down Expand Up @@ -1099,6 +1100,7 @@ class OBS

void RefreshStreamButtons(bool disable=false);
void ConfigureStreamButtons();
void PostConfigureStreamButtons();

void ReloadIniSettings();

Expand Down
4 changes: 4 additions & 0 deletions Source/WindowStuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fadce38

Please sign in to comment.