Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Fix cast of pointer type at invalid current scene setting on load #11010

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

norihiro
Copy link
Contributor

@norihiro norihiro commented Jul 20, 2024

Description

A variable curScene has a type OBSSourceAutoRelease.
It's pointer &curScene is passed to obs_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.

  • Use static_cast instead of reintepret_cast so that some type-checks will be performed at compile time.
  • Instead of having a reference type of OBSSourceAutoRelease, put the parameter source_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

  1. Created a new scene collection having one scene named Scene.
  2. Manually edit the scene collection file as below and start OBS Studio.
@@ -61,8 +61,8 @@
     "monitoring_type": 0,
     "private_settings": {}
   },
-  "current_scene": "Scene",
-  "current_program_scene": "Scene",
+  "current_scene": "Scene 1",
+  "current_program_scene": "Scene 1",
   "scene_order": [
     {
       "name": "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

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Jul 20, 2024
@RytoEX
Copy link
Member

RytoEX commented Jul 20, 2024

cc @Penwy @notr1ch

@RytoEX RytoEX requested a review from notr1ch July 20, 2024 01:36
@RytoEX RytoEX added this to the OBS Studio 31 milestone Jul 20, 2024
@RytoEX
Copy link
Member

RytoEX commented Jul 20, 2024

@Lain-B Lain-B merged commit 2fa77c4 into obsproject:master Jul 20, 2024
15 checks passed
@norihiro norihiro deleted the fix-curScene-type branch July 24, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants