Skip to content

Commit 1c3330f

Browse files
committed
Fix actiongroupswitch fetching persistent variables on startup
1 parent df8d7e9 commit 1c3330f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

RasterPropMonitor/Auxiliary modules/JSIActionGroupSwitch.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ public void Start()
482482
persistentVarValid = !string.IsNullOrEmpty(persistentVarName);
483483
if (persistentVarValid)
484484
{
485-
// fetch the variable once before registering a callback for it, because otherwise the default value will be -1 on creation
486-
rpmComp.GetPersistentVariable(persistentVarName, initialState, perPodPersistenceIsGlobal);
485+
if (!rpmComp.HasPersistentVariable(persistentVarName, perPodPersistenceIsGlobal))
486+
{
487+
rpmComp.SetPersistentVariable(persistentVarName, initialState, perPodPersistenceIsGlobal);
488+
}
487489
rpmComp.RegisterVariableCallback("PERSISTENT_" + persistentVarName, PersistentVarChangedCallback);
488490
}
489491
}

0 commit comments

Comments
 (0)