Accessing class during module shutdown results in access violation.

During a module’s “PreUnloadCallback” and “ShutdownModule” a call to GetMutableDefault results in a crash.

void FSomePluginEditorModule::PreUnloadCallback() {
    UUMGEditorProjectSettings* Settings = GetMutableDefault<UUMGEditorProjectSettings>(false);
}

UObject\Class.h:

If I want to run an uninstaller when my plugin shuts down / unloads, which happens to access engine classes such as UUMGEditorProjectSettings, then where can I do this safely? Is there a check to see if the engine itself is already shutting down?

:crescent_moon:

Up

Maybe subclass the engine subsystem, then override the Deinitialize function? The deinit is called after the modules are shut down I believe.

Thinking about it a bit more, may not meet your needs but may be a good place to peek around for a place to inject your function…

Optimally the module itself manages its own cleanup, is there any reliable point in shutdown procedure it can initiate an “uninstall” option, to for example clean up the project settings? When I access the project settings during module shutdown it will crash on GetMutableDefault.

I see. That’s not an easy problem.
I can’t think of a way immediately… I’ll keep it in mind and come back if I run into anything.

1 Like