mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
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:
parent
9229107bab
commit
cc77724229
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user