Tips

Post Reply
ColinP
Posts: 939
Joined: Mon Aug 03, 2020 7:46 pm

Tips

Post by ColinP »

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.
Centripidity
Posts: 140
Joined: Sun Jan 22, 2023 5:18 am
Location: Melbourne
Contact:

Re: Tips

Post by Centripidity »

Colin,

Thanks for taking the time share.

Peter
UrbanCyborg
Posts: 588
Joined: Mon Nov 15, 2021 9:23 pm

Re: Tips

Post by UrbanCyborg »

ColinP: Always supply name strings to VoltageComponent constructors as in rare circumstances not doing so creates inexplicable behaviour in the event handling.
Meaning, "pass in a string?" Any string? Or did you mean something else? Sorry to be obtuse.

Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
ColinP
Posts: 939
Joined: Mon Aug 03, 2020 7:46 pm

Re: Tips

Post by ColinP »

UrbanCyborg wrote: Fri May 26, 2023 8:20 pm
ColinP: Always supply name strings to VoltageComponent constructors as in rare circumstances not doing so creates inexplicable behaviour in the event handling.
Meaning, "pass in a string?" Any string? Or did you mean something else? Sorry to be obtuse.

Reid
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...

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" );
UrbanCyborg
Posts: 588
Joined: Mon Nov 15, 2021 9:23 pm

Re: Tips

Post by UrbanCyborg »

Thanks for the clarification, Colin.

Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
Post Reply

Return to “Module Designer”