-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Effects refactoring: loaded effect #4426
Conversation
src/effects/effectslot.cpp
Outdated
m_pManifest = pManifest; | ||
|
||
if (!pManifest || !pEffectPreset) { | ||
// No new effect to load; just unload the old effect and return. | ||
emit effectChanged(); | ||
return; | ||
} | ||
|
||
m_pManifest = pManifest; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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();
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
I have cherry picked these commits to my branch except for 8c77516. |
Now that I have started to prepare the effects refactoring branch. I expect the swapped roles in a normal review process. This will also give others the chance to give comments and merge in case we are at a different opinion. |
Okay, sorry, I was not clear what workflow you were expecting. Rebase to remove 8c77516 and we can merge this. |
4141b2d
to
02e7b6a
Compare
Done. |
This fixes some review issues #2618 around EffectSlot and loaded_effect.
See commits.