UI: Fix cast of pointer type at invalid current scene setting on load #11010
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A variable
curScene
has a typeOBSSourceAutoRelease
.It's pointer
&curScene
is passed toobs_enum_scenes
.Hence, the right type is
OBSSourceAutoRelease *
.Though the first commit 496e599 fixed the bug, there was a complaint that the code is not easy to read. This PR additionally change them for a little better readability of the code.
static_cast
instead ofreintepret_cast
so that some type-checks will be performed at compile time.OBSSourceAutoRelease
, put the parametersource_ptr
with the cast to the left hand side of the assignment.Motivation and Context
The code was introduced by #9944.
A crash was reported on the forum. https://obsproject.com/forum/attachments/crash-2024-07-18-09-59-21-txt.105470/
How Has This Been Tested?
OS: Fedora 39
Scene
.Without this fix, I confirmed the crash was reproduced.
With this fix, I confirmed no crash was observed and
Scene
was selected at the startup.Also checked with Studio Mode.
Types of changes
Checklist: