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

libobs,UI: Replace and deprecate obs_scene_sceneitem_from_source #11251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gxalpha
Copy link
Member

@gxalpha gxalpha commented Sep 7, 2024

Description

obs_scene_sceneitem_from_source is problematic because there can be multiple items of the same source in a scene, which the function doesn't account for. In such a case, it would return the first item it finds, which often might not be what a developer expects.
It was originally added for the undo/redo-operation of "Add New Source" where the UI guarantees that the item is unique, but for a general case it's not suitable.

In the one UI use, instead of first creating the scene item and then finding it again , we can just remember the scene item in AddNew after we create it, similar to the source itself.

Motivation and Context

The existence of the method was discussed on Discord, and I think it shouldn't exist.

How Has This Been Tested?

macOS 15
Added and undo/redo'd (redid?) new sources without problems.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

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.

@gxalpha gxalpha added the Code Cleanup Non-breaking change which makes code smaller or more readable label Sep 7, 2024
@gxalpha gxalpha force-pushed the remove-obs_scene_sceneitem_from_source branch 2 times, most recently from 3cd4dfc to 2df0baf Compare September 11, 2024 14:13
Instead of first creating the scene item and then finding it again using
a method that's generally problematic (and only works here because we
know that there is only one instance of a source), let's just remember
the scene item in AddNew after we create it, similar to the source
itself.
obs_scene_sceneitem_from_source is problematic because there can be
multiple items of the same source in a scene, which the function doesn't
account for. In such a case, it would return the first item it finds,
which often might not be what a developer expects.

It was originally added for the undo/redo-operation of "Add New Source"
where the UI guarantees that the item is unique, but for a general case
it's not suitable.
@gxalpha gxalpha force-pushed the remove-obs_scene_sceneitem_from_source branch from 2df0baf to d4c8e93 Compare September 11, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup Non-breaking change which makes code smaller or more readable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants