Propery Manager not loading saved values

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
medelec35
Valued Contributor
Posts: 2410
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 768 times
Been thanked: 830 times

Flowcode v11 Propery Manager not loading saved values

Post by medelec35 »

Hi Ben.
If it's my mistake I will move this topic to general
I would like to save an load property values within PC Developer deployed app.
After changing the property value running the app and selecting the save switch, I get the Are you sure you want to save prompt.
Select Stop, reload and run the app that will now have the original value, select Load switch and get the Are you sure you want to load prompt.
The Property does not change to the saved value, although its the correct value within the generate Config file.

Is Property Manager and CSV Read/Write compatible with Event APIs? As using within Ev_Initalise , Ev_Properties, Ev_ProjectClosedown etc causes a 0B blank config file or duplicated entries.
I'm trying to set up auto saving and loading of properties.
Attachments
Property Manager Test.fcpcd
(14.22 KiB) Downloaded 3 times
(view online)
Martin

medelec35
Valued Contributor
Posts: 2410
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 768 times
Been thanked: 830 times

Flowcode v11 Re: Propery Manager not loading saved values

Post by medelec35 »

Hi Ben.
As an experiment, I gave AI the Property Manager component to investigate, and produced an updated file very quickly, and it works!
Ai Stated:
Yes — I can see it directly in the PropertyManager.fcsx source, no guessing needed. It's a real bug in the component itself, in how it handles bare/root-level properties (ones registered without a Component:: prefix, like UpdateRate).

Here's the actual mismatch, line by line:

In RegisterProperty (line 390-392), the handle starts as Component.GetRoot(). If the property name you register has no :: in it at all (a bare property), the loop that would normally call Component.FindChild never runs, so Handles[NumProps] ends up storing the root panel's handle.

In Save (line 145), the check is Handles[.idx] == this. But this in this macro means PropertyManager1's own handle, not the root panel's handle. Since a bare property's stored handle is the root handle, not PropertyManager1's own handle, this comparison is always false for bare properties. So instead of writing the literal string this::UpdateRate,5, it falls through to the else branch and writes Tree.GetName(Handles[.Idx]) — the actual name of the root panel (e.g. Main::UpdateRate,5).

Then in Load (line 290), it reads that component-name token back and checks .SubStr != "this". Since the token is the panel's real name (not literally "this"), this is true, so it calls Component.FindChild(.Handle, .SubStr) — trying to find a child of root literally named the same as the root panel itself. That fails, because the root isn't a child of itself. .Handle comes out of that call invalid/wrong.

That broken handle is what then gets passed into Component.Property.SetValue(.Handle, .PropName, .SubStr) — targeting the wrong (or no) component, so the bare property never actually updates, even though the value in the file is correct.

So the fix on Flowcode's end would be either: compare Handles[.idx] == Component.GetRoot() in Save instead of == this, or have Load specifically special-case when the resolved handle equals root. Either way, this is a real, source-confirmed bug specific to bare/root-level registered properties
Attached is the update file an component without the icon.
Attachments
PropertyManager.fcpx
(3.92 KiB) Downloaded 3 times
PropertyManager.fcsx
(28.46 KiB) Downloaded 3 times
(view online)
Martin

WingNut
Posts: 286
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 55 times
Been thanked: 43 times

Re: Propery Manager not loading saved values

Post by WingNut »

Hi Martin. For my curiosity, which Ai did you use?

N

Post Reply