HISE
HISE copied to clipboard
[Question] Audio Thread Guard is Now Flagging Hardcoded Strings in Realtime Callbacks
I ff'd from a81cdc5a8c0c69c407672c1aebe1f00c424209a3 to the latest commit and the ATG is now throwing an Illegal Operation error for dynamic object access that it was previously not flagging.
I have since switched the data model to fix this but wanted to bring this up as I'm curious whether this is intended.
I used to have an object property ControlValue.mtStr = ["mtValue1", "mtValue2", "mtValue3 etc."]
. These are hardcoded and assigned at compilation. These strings are referencing property IDs of the same object, and they contain control values. They're created using a callable control helper function that I use for all buttons.
I would then, in a realtime callback, use ControlValue[ControlValue.mtStr[i]]
in order to access the ControlValue.mtValue1
, ControlValue.mtValue2
etc. properties from a for loop, checking the value. Before I learned about the Thread Guard, I did string concatenation here to do that (ControlValue["mtValue" + (i+1)]
. Since learning that this is a big no-no, I switched over to the aforementioned model where I use the strings stored in an array to do dynamic access.
In the latest commit, even this is flagged as evil by ATG so I just created an array that copies the values when they change, and am accessing them using standard array index access.
Was this kind of dynamic access with a compiled string unsafe? Or is the Thread guard now just assuming the worst for any kind of dynamic object access?