Having wasted a couple of days tracking mysterious bugs, here's a couple of tips.
Do not try to dynamically resize VoltageCanvas objects, instead create new objects, calling RemoveChildComponent() where appropriate to remove clutter and give the GC a chance.
Always supply name strings to VoltageComponent constructors as in rare circumstances not doing so creates inexplicable behaviour in the event handling.
I could go in to details but time is precious especially when you've wasted a lot of it.
Don't worry about the above if you are new to developing for VM as you'll only encounter these situations when working at the bleeding edge.
Tips
-
- Posts: 146
- Joined: Sun Jan 22, 2023 5:18 am
- Location: Melbourne
- Contact:
Re: Tips
Colin,
Thanks for taking the time share.
Peter
Thanks for taking the time share.
Peter
-
- Posts: 625
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Tips
Meaning, "pass in a string?" Any string? Or did you mean something else? Sorry to be obtuse.ColinP: Always supply name strings to VoltageComponent constructors as in rare circumstances not doing so creates inexplicable behaviour in the event handling.
Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: Tips
My bad. I wanted to alert others but felt a little too stretched at the time to explain. Custom is taking a lot of effort as there's a mind-boggling amount of detailed work involved and dealing with "quirks" in the API is frustrating. Still I have made good progress today and have no bugs left on my list. So...UrbanCyborg wrote: ↑Fri May 26, 2023 8:20 pmMeaning, "pass in a string?" Any string? Or did you mean something else? Sorry to be obtuse.ColinP: Always supply name strings to VoltageComponent constructors as in rare circumstances not doing so creates inexplicable behaviour in the event handling.
Reid
When doing programmatic model construction the name and displayName constructor parameters (called Internal Name and Display Name in VMD) can be set to unique strings, "" or even null.
For some components like labels these names don't have much real meaning as they don't need to have keyed associations for value persistence, patching or remote control. Therefore the temptation is to use "". However in some (but not all) situations doing so causes the initialisation SetValue events of OTHER components to go missing. Yes OTHER components not the ones with no names.
It's freakish secondary symptomatic behaviour and took some serious diagnostics to pinpoint.
So I now always pass a name string even though it's meaningless. You can use the same string for both names and I use simple code like this to automatically generate names...
name = "label" + id;
label = new VoltageLabel( name, name, module, "TEST" );
-
- Posts: 625
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Tips
Thanks for the clarification, Colin.
Reid
Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76