Plugin uninstaller. Access during module shutdown == 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

If you need an example why, take a look at the Enhanced Input plugin. when you disable that plugin it doesn’t clean up, leaving the “player input” and “input component” property in the project settings on the enhanced input value. It could have, if they wrote an uninstaller, reverted back to the engine’s default. Not so nice. So is it possible to write such module uninstaller and inject it at a point it can still safely access modules it depends on to clean up there?