RequestHandler: More simplification (and fix)

obs_queue_task is set to wait, so there is no need to create our
bool on the stack, as it should never go out of scope when the task
is run. Additionally, the old way didn't actually work anyway.
This commit is contained in:
tt2468 2021-06-16 08:16:23 -07:00
parent 9229107bab
commit cc77724229

View File

@ -129,13 +129,12 @@ RequestResult RequestHandler::SetStudioModeEnabled(const Request& request)
// Avoid queueing tasks if nothing will change
if (obs_frontend_preview_program_mode_active() != request.RequestData["studioModeEnabled"]) {
// (Bad) Create a boolean on the stack, then free it after the task is completed. Requires `wait` in obs_queue_task() to be true
bool *studioModeEnabled = new bool(request.RequestData["studioModeEnabled"]);
bool studioModeEnabled = request.RequestData["studioModeEnabled"];
// Queue the task inside of the UI thread to prevent race conditions
obs_queue_task(OBS_TASK_UI, [](void* param) {
bool studioModeEnabled = (bool*)param;
obs_frontend_set_preview_program_mode(&studioModeEnabled);
}, studioModeEnabled, true);
delete studioModeEnabled;
bool *studioModeEnabled = (bool*)param;
obs_frontend_set_preview_program_mode(*studioModeEnabled);
}, &studioModeEnabled, true);
}
return RequestResult::Success();