Merge pull request #754 from Areloch/callOnNestedExecFix

Fixes issue where nested callOnModules would thrash the queued exec lists from other invokes
This commit is contained in:
Brian Roberts 2022-03-27 16:30:23 -05:00 committed by GitHub
commit 3e39347167
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 26 deletions

View file

@ -6,7 +6,8 @@ if (!isObject(ExecFilesList))
function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6) function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
{ {
//clear per module group file execution chain //clear per module group file execution chain
ExecFilesList.empty(); %execArray = new ArrayObject("callOn" @ %functionName @ "_" @ %moduleGroup);
ExecFilesList.push_back(%execArray);
//Get our modules so we can exec any specific client-side loading/handling //Get our modules so we can exec any specific client-side loading/handling
%modulesList = ModuleDatabase.findModules(false); %modulesList = ModuleDatabase.findModules(false);
for(%i=0; %i < getWordCount(%modulesList); %i++) for(%i=0; %i < getWordCount(%modulesList); %i++)
@ -23,12 +24,21 @@ function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3,
%module.scopeSet.call(%functionName, %var0, %var1, %var2, %var3, %var4, %var5, %var6); %module.scopeSet.call(%functionName, %var0, %var1, %var2, %var3, %var4, %var5, %var6);
} }
%execFilecount = ExecFilesList.count(); %execFilecount = %execArray.count();
if($traceModuleCalls)
{
error("ExecFilesList at actual exec point:");
%execArray.echo();
}
for (%i=0;%i<%execFilecount;%i++) for (%i=0;%i<%execFilecount;%i++)
{ {
%filename = ExecFilesList.getKey(%i); %filename = %execArray.getKey(%i);
exec(%filename); exec(%filename);
} }
ExecFilesList.pop_back(); //cleanup
} }
function loadModuleMaterials(%moduleGroup) function loadModuleMaterials(%moduleGroup)
@ -213,7 +223,7 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
return; return;
} }
if(!isObject(ExecFilesList)) if(!isObject(ExecFilesList) || ExecFilesList.count() == 0)
{ {
error("Module::queueExec() - ExecFilesList array object doesn't exist!"); error("Module::queueExec() - ExecFilesList array object doesn't exist!");
return; return;
@ -225,10 +235,11 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
%fullPath = pathConcat(%moduleDef.ModulePath, %execFilePath); %fullPath = pathConcat(%moduleDef.ModulePath, %execFilePath);
///go through all entries ///go through all entries
%locked = false; %locked = false;
%execFilecount = ExecFilesList.count(); %execFileList = ExecFilesList.getKey(ExecFilesList.count()-1);
%execFilecount = %execFileList.count();
for (%i=0;%i<%execFilecount;%i++) for (%i=0;%i<%execFilecount;%i++)
{ {
%check = ExecFilesList.getKey(%i); %check = %execFileList.getKey(%i);
//look for a substring match //look for a substring match
%isMatch = strIsMatchExpr("*"@ strReplace(%execFilePath,"./","/"),%check ); %isMatch = strIsMatchExpr("*"@ strReplace(%execFilePath,"./","/"),%check );
if (%isMatch) if (%isMatch)
@ -237,13 +248,13 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
//and kill off any duplicates //and kill off any duplicates
//do note that doing it in this order means setting exclusive twice //do note that doing it in this order means setting exclusive twice
//allows one to override exclusive with exclusive //allows one to override exclusive with exclusive
%locked = ExecFilesList.getValue(%i); %locked = %execFileList.getValue(%i);
if ((%locked && !%isExclusive)&&($reportModuleFileConflicts)) if ((%locked && !%isExclusive)&&($reportModuleFileConflicts))
error("found" SPC %execFilePath SPC "duplicate file!"); error("found" SPC %execFilePath SPC "duplicate file!");
if (%isExclusive) if (%isExclusive)
{ // Replacing an existing entry, update in-place { // Replacing an existing entry, update in-place
ExecFilesList.setKey(%fullPath, %i); %execFileList.setKey(%fullPath, %i);
ExecFilesList.setValue(%isExclusive, %i); %execFileList.setValue(%isExclusive, %i);
%locked = true; //Done, but don't return and bypass trace logging below %locked = true; //Done, but don't return and bypass trace logging below
} }
break; break;
@ -251,9 +262,9 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
} }
//if we're not locked, go ahead and add it to the pile //if we're not locked, go ahead and add it to the pile
if (!%locked) if (!%locked)
ExecFilesList.add(%fullPath,%isExclusive); %execFileList.add(%fullPath,%isExclusive);
if ($traceModuleCalls) if ($traceModuleCalls)
ExecFilesList.echo(); %execFileList.echo();
} }
function SimSet::unQueueExec(%scopeSet, %execFilePath) function SimSet::unQueueExec(%scopeSet, %execFilePath)
@ -269,7 +280,7 @@ function SimSet::unQueueExec(%scopeSet, %execFilePath)
return; return;
} }
if(!isObject(ExecFilesList)) if(!isObject(ExecFilesList) || ExecFilesList.count() == 0)
{ {
error("Module::unRegisterDatablock() - ExecFilesList array object doesn't exist!"); error("Module::unRegisterDatablock() - ExecFilesList array object doesn't exist!");
return; return;
@ -280,23 +291,24 @@ function SimSet::unQueueExec(%scopeSet, %execFilePath)
%fullPath = pathConcat(%moduleDef.ModulePath, %relativePath); %fullPath = pathConcat(%moduleDef.ModulePath, %relativePath);
///go through all entries ///go through all entries
%locked = false; %locked = false;
%execFilecount = ExecFilesList.count(); %execFileList = ExecFilesList.getKey(ExecFilesList.count()-1);
%execFilecount = %execFileList.count();
for (%i=0;%i<%execFilecount;%i++) for (%i=0;%i<%execFilecount;%i++)
{ {
%check = ExecFilesList.getKey(%i); %check = %execFileList.getKey(%i);
//look for a substring match //look for a substring match
%isMatch = strIsMatchExpr("*"@ %execFilePath,%check ); %isMatch = strIsMatchExpr("*"@ %execFilePath,%check );
if (%isMatch) if (%isMatch)
{ {
//check if we're already locked in. if not, kill it. //check if we're already locked in. if not, kill it.
%locked = ExecFilesList.getValue(%i); %locked = %execFileList.getValue(%i);
if (!%locked) if (!%locked)
{ {
ExecFilesList.erase(%i); %execFileList.erase(%i);
} }
} }
} }
if ($traceModuleCalls) if ($traceModuleCalls)
ExecFilesList.echo(); %execFileList.echo();
} }

View file

@ -4,15 +4,7 @@ $guiContent = new GuiControl(OptionsMenu) {
profile = "GuiDefaultProfile"; profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
isContainer = "1"; isContainer = "1";
canSaveDynamicFields = "1"; canSaveDynamicFields = "0";
currentCategory = "Display";
optionsCategories = "17177";
pageTabIndex = "0";
returnGui = "MainMenuGui";
tamlReader = "20088";
tile = "0";
unappliedChanges = "17178";
useVariable = "0";
new GuiControl() { new GuiControl() {
position = "48 56"; position = "48 56";