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

Effects refactoring: loaded effect #4426

Merged

Conversation

daschuer
Copy link
Member

This fixes some review issues #2618 around EffectSlot and loaded_effect.
See commits.

Comment on lines 290 to 293
m_pManifest = pManifest;

if (!pManifest || !pEffectPreset) {
// No new effect to load; just unload the old effect and return.
emit effectChanged();
return;
}

m_pManifest = pManifest;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks wrong. m_pManifest being nullptr indicates that the EffectSlot is empty, which needs to happen before this function returns.

Copy link
Member Author

Choose a reason for hiding this comment

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

m_pManifest is always cleared at this point.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, if loading nullptr this function would return before setting m_pManifest to nullptr.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is already cleared via unloadEffect();

Copy link
Contributor

@Be-ing Be-ing Oct 15, 2021

Choose a reason for hiding this comment

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

Okay, but that's not obvious. There's no benefit to this change; it only makes the code harder to read. Rebase to remove this commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well then a DEBUG_ASSERT must be added instead of implicitly assuming unloadEffect does what the caller expects.

Copy link
Member

Choose a reason for hiding this comment

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

Daniel just pointed the actual bug out that I didn't even spot after telling me there is one. The problem occurs when calling loadEffectInner with pManifest being valid but pEffectPreset being nullptr. The slot would result in being unloaded, but having a valid m_pManifest. From what I can tell, this violates an invariant.
The proposed change would eliminate the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. The DEBUG_ASSERT is still needed.

Copy link
Member

Choose a reason for hiding this comment

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

So have we found the consensus of sticking with the reordering but adding a debug assert between unloadEffect and return?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I think a debug assertion should be added checking that pEffectPreset is not nullptr when pManifest is valid.

@Be-ing
Copy link
Contributor

Be-ing commented Oct 15, 2021

I have cherry picked these commits to my branch except for 8c77516.

@Be-ing Be-ing closed this Oct 15, 2021
@daschuer daschuer reopened this Oct 15, 2021
@daschuer
Copy link
Member Author

Now that I have started to prepare the effects refactoring branch. I expect the swapped roles in a normal review process.
https://github.com/mixxxdj/mixxx/tree/effects_refactoring is the new branch where i want to consolidate the changes.
I cannot work with #2618 because of all the collapsed dialogs.

This will also give others the chance to give comments and merge in case we are at a different opinion.

@Be-ing
Copy link
Contributor

Be-ing commented Oct 15, 2021

Okay, sorry, I was not clear what workflow you were expecting. Rebase to remove 8c77516 and we can merge this.

@daschuer daschuer force-pushed the effects_refactoring branch from 4141b2d to 02e7b6a Compare October 18, 2021 06:33
@daschuer
Copy link
Member Author

Done.

@Be-ing Be-ing merged commit 64944d3 into mixxxdj:effects_refactoring Oct 18, 2021
@daschuer daschuer deleted the effects_refactoring_loaded_effect branch April 14, 2022 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants