libobs,UI: Replace and deprecate obs_scene_sceneitem_from_source #11251
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
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
Checklist: