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: Restore frontend API events being dispatched during initialization #11450

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

PatTheMav
Copy link
Member

Description

Restore dispatch of frontend events that have not been dispatched due to prior refactor.

Motivation and Context

The frontend API events "OBS_FRONTEND_EVENT_SCENE_CHANGED" and "OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED" are not dispatched if disableSaving has a value > 0. Prior code decremented disableSaving to 0 globally (regardless of whether saving was necessary, which is only the case if a new collection is created as a fallback for a missing scene collection).

Thus the updated code exhibits different event dispatch behavior then old code which some plugins might have relied on. To avoid introducing new behavior, explicitly create the environment to allow the dispatch to take place and remove/refactor the events in a later version.

How Has This Been Tested?

Checked frontend dispatch taking place with existing scene collection, scene collection name provided via command-line argument as well as with missing scene collection.

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.

Copy link
Collaborator

@Lain-B Lain-B left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would have been called elsewhere but I guess we need to explicitly call them 🤔

@gxalpha
Copy link
Member

gxalpha commented Oct 26, 2024

I haven't been able to check whether it's actually the case, but noticed in code OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED and OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED may also be effected. Noting this down so that it maybe doesn't get forgotten.

@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Oct 26, 2024
@Lain-B
Copy link
Collaborator

Lain-B commented Oct 26, 2024

Yeah doesn't prevent this one from being merged but it would probably be good to double-check any others if we suspect they could be affected.

@PatTheMav
Copy link
Member Author

I thought this would have been called elsewhere but I guess we need to explicitly call them 🤔

They are called before, but disableSaving is always non-zero (and has to be in the case of existing collections, otherwise they might be overwritten by half-initialised collection state at program start), so no actual dispatch happens.

IMO it is more correct that none of these events are dispatched before OBS is initialised, but that change should happen after communicating this change, so I'm fine with adding workarounds for them until then.

Copy link
Member

@gxalpha gxalpha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm that this solves the situation where I found the problem.

@RytoEX RytoEX added this to the OBS Studio 31 milestone Oct 29, 2024
Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: initialisation -> initialization

Looks good otherwise.

The frontend API events "OBS_FRONTEND_EVENT_SCENE_CHANGED" and
"OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED" are not dispatched if
disableSaving has a value > 0. Prior code decremented disableSaving to
0 globally (regardless of whether saving was necessary, which is only
the case if a new collection is created as a fallback for a missing
scene collection).

Thus the updated code exhibits different event dispatch behavior then
old code which some plugins might have relied on. To avoid introducing
new behavior, explicitly create the environment to allow the dispatch
to take place and remove/refactor the events in a later version.
@RytoEX RytoEX changed the title UI: Restore frontend API events being dispatched during initialisation UI: Restore frontend API events being dispatched during initialization Oct 30, 2024
@RytoEX RytoEX merged commit 1cf6b3d into obsproject:master Oct 30, 2024
14 checks passed
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.

5 participants