Skip to content

Commit 673c1ec

Browse files
committed
Fixed crash when going back to main menu
1 parent 8ef05b3 commit 673c1ec

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

UIExtenderLibModule/UIExtenderLibModule.cs

+18
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,27 @@ public class UIExtenderLibModule: MBSubModuleBase
2323
// view model component instance
2424
internal readonly ViewModelComponent ViewModelComponent = new ViewModelComponent();
2525

26+
// flag to check for single process call
27+
private static bool _processedExtensions = false;
28+
2629
protected override void OnBeforeInitialModuleScreenSetAsRoot()
2730
{
2831
base.OnBeforeInitialModuleScreenSetAsRoot();
32+
33+
/*
34+
* This method is run every time MainMenu appears, which could happen multiple times
35+
* during single application run.
36+
*
37+
* Code to apply extensions should be run after all of the mods has been loaded, therefore it could not
38+
* be placed in `OnSubModuleLoad`.
39+
*
40+
* In order to only run it once this flag is implemented.
41+
*/
42+
if (_processedExtensions)
43+
{
44+
return;
45+
}
46+
_processedExtensions = true;
2947

3048
// apply registered extensions
3149
foreach (var extensionType in UIExtender.Extensions)

0 commit comments

Comments
 (0)