Skip to content

Commit

Permalink
Added check if scope is set to private but SetByDerived is true
Browse files Browse the repository at this point in the history
fixes #1314
  • Loading branch information
vchelaru committed Dec 31, 2023
1 parent 1025b8a commit 0e731f5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions FRBDK/Glue/Glue/SetProperty/CustomVariableSaveSetPropertyLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ private static void HandleIsSharedVariableSet(CustomVariable customVariable, obj
bool didErrorOccur = false;
if (customVariable.SetByDerived && customVariable.IsShared)
{
MessageBox.Show("Variables which are SetByDerived cannot set IsShared to true");
GlueCommands.Self.DialogCommands.ShowMessageBox("Variables which are SetByDerived cannot set IsShared to true");
didErrorOccur = true;
}

if (customVariable.GetIsExposingVariable(GlueState.Self.CurrentElement) && customVariable.IsShared)
{
MessageBox.Show("Exposed variables cannot set IsShared to true");
GlueCommands.Self.DialogCommands.ShowMessageBox("Exposed variables cannot set IsShared to true");
didErrorOccur = true;
}

Expand Down Expand Up @@ -484,8 +484,23 @@ private void HandleScopeSet(CustomVariable customVariable, object oldValue)

var newScope = customVariable.Scope;

SetDerivedElementVariables(owner, customVariable.Name, newScope);
var didErrorOccur = false;

if(newScope == Scope.Private && customVariable.SetByDerived)
{
GlueCommands.Self.DialogCommands.ShowMessageBox($"The variable {customVariable.Name} has its scope set to {newScope}, but it also has its SetByDerived to true " +
$"(requiring the variable to be virtual) which will result in compile errors. To set the scope to {newScope}, change SetByDerived to false.");
didErrorOccur = true;
}

if(didErrorOccur)
{
customVariable.Scope = (Scope)oldValue;
}
else
{
SetDerivedElementVariables(owner, customVariable.Name, newScope);
}
}

private void SetDerivedElementVariables(IElement owner, string name, Scope newScope)
Expand Down

0 comments on commit 0e731f5

Please sign in to comment.