Can you add line number for error "You must specify the unique component name, not the object itself”?
-
This error has chased me for ages and I know what chunk of code it belongs to but can’t find a fix.
function createPreset(displayName, target, parent, column, row, preset) { reg qsW = 120; reg qsH = 22; reg margin = 5; reg qsX = margin + column * (qsW + margin); reg qsY = margin + row * (qsH + margin); reg qsBg = 0x11FFFFFF; reg qsItem = Content.addPanel("qs" + target, 10 + qsX, 10 + qsY); Content.setPropertiesFromJSON("qs" + target, { "parentComponent": parent, "text": [displayName, target, preset], "width": qsW, "height": qsH, "allowCallbacks": "Clicks & Hover", });
-
@Fergler
parent
must be a string, not a reference to the UI object -
And if the script error doesn't contain the line information (some errors appear in a context that doesn't know about the scripting code), you can always use the assertion methods from the Console to get a nice stack trace:
inline function call2(parent) { Console.assertEqual(typeof(parent), "string"); } function call1(p) { call2(p); } const var k = Content.addKnob("k", 0, 0); call1("1234"); call1(k);
yields:
Master Chain:! Assertion failure: values are unequal {SW50ZXJmYWNlfG9uSW5pdCgpfDg5fDd8MjE=} : call2() - Line 7, column 21 {SW50ZXJmYWNlfG9uSW5pdCgpfDg5fDd8MjE=} : onInit() - Line 12, column 2 {SW50ZXJmYWNlfHwxMzZ8MTJ8Mg==}
-
@Fergler Why are you using a function and not an inline function?
-
Parent is a string, I should have included my function call:
Quickset.createPreset("Close Skins", "Close Skins", "QS Dropdown", 0, 1, [
["KickPunch", 0.5],
["SnarePunch", 1],
]);That’s where I’m getting so confused, I can’t find any objects that could be throwing this error. :/
DHealey
In this case it’s because otherwise I get "Can't reference inline function parameters in nested function body” with some other things going on next to it.Efficiency is not an issue in this part as it’s all develop only generation of the UI XML, this code won’t ship.
-
@Fergler said in Can you add line number for error "You must specify the unique component name, not the object itself”?:
It is an inline function
I see, you should use
local
variables within inline functions rather than reg. -
I edited to fix completely tired misinformation etc in my post but yes I had a bunch of regs left over from misusing them and basically haven’t bothered since this is in module and UI builder code but yes I’ll change them.
Taking a 5 month leave from working on this has not been great :D