-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
midi-components: Fix undefined CO group on EffectUnit initialization #2948
Conversation
Before, the code caused a warning like this for each EffectUnit on script load: Warning [Controller]: ControlDoublePrivate::getControl returning NULL for ( "" , "controller_input_active" ) This was caused by PR mixxxdj#2322. The code tries to use the component's group in `setCurrentUnit` even though it's not set until later in the code.
@@ -818,21 +818,20 @@ | |||
this.setCurrentUnit(this.unitNumbers[index]); | |||
}; | |||
|
|||
if (unitNumbers !== undefined) { |
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.
Why did you remove this check?
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.
Because it's superfluous and insufficient. The warning should be printed if unitNumbers
is neither an array or a number. This is the case now. Before, the warning was only printed if it was undefined
, but not if it was null
or an object.
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.
The problem is that QScriptEngine stops executing silently when trying to do anything with an undefined variable besides check it is undefined.
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.
Really? That sounds like an absolutely critical bug... Is that fixed with QJSEngine?
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 bug has always been there...
@@ -818,9 +818,9 @@ | |||
this.setCurrentUnit(this.unitNumbers[index]); | |||
}; | |||
|
|||
if (Array.isArray(unitNumbers)) { | |||
if (unitNumbers !== undefined && Array.isArray(unitNumbers)) { |
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.unitNumbers
is still accessed below. How about checking unitNumbers === undefined
once before this if/else block?
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.
... But it returns in line 826, before it's accessed?
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.
@Be-ing ping
Merge? |
@Be-ing ping |
pong |
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.
Seems like Be is very busy atm so I took the liberties to review instead.
The changes seem reasonable apart from the unitNumbers check.
I didn't test whether this PR actually fixes the issue reported, but at least it doesn't seem to break anything else.
// These must be unique to each instance, | ||
// so they cannot be in the prototype. | ||
this.deckNumbers = deckNumbers; | ||
} else if (deckNumbers !== undefined && typeof deckNumbers === "number" && |
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.
Can we skip checking deckNumbers !== undefined
twice?
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.
You have an idea how? I introduced that check in 6f0c690 because according to Be the QtScriptEngine behaves weird if it's undefined: https://github.com/mixxxdj/mixxx/pull/2948/files/21cafe18eba551ddb970299fef40458b6e2adb40#diff-9bedde251ff7d14d89b40d05168275e4
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.
I was just thinking about extracting that into its own check like there was before.
if (deckNumbers !== undefined) {
if (Array.isArray(deckNumbers)) { ... }
else if (typeof deckNumbers === "number" && ...) {...}
}
}
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.
And in case deckNumbers is not undefined and neither an array nor a number?
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.
Ah, right, that would result in more duplicated code. You are right, the code is fine as-is.
} | ||
if (unitNumbers !== undefined && Array.isArray(unitNumbers)) { | ||
this.unitNumbers = unitNumbers; | ||
} else if (unitNumbers !== undefined && typeof unitNumbers === "number" && |
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 double unitNumbers check again
OK, can we merge then? |
No need to wait any longer. @Swiftb0y already approved the PR. LGTM |
Before, the code caused a warning like this for each EffectUnit on
script load:
This was caused by PR #2322. The code tries to use the component's group
in
setCurrentUnit
even though it's not set until later in the code.