Adding a Module to Plugin crashes Unreal Engine: "Assertion failed: IsValid() UE_4.26\...\Templates/SharedPointer.h [Line: 890]"

Update :

In the code generated for the “Editor Standalone Window” preset, in MyPluginEditorStyle.cpp, there is this function:

TSharedRef< FSlateStyleSet > FMyPluginEditorStyle::Create()
{
	TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("MyPluginEditorStyle"));
	Style->SetContentRoot(IPluginManager::Get().FindPlugin("MyPluginEditor")->GetBaseDir() / TEXT("Resources"));

	Style->Set("MyPluginEditor.OpenPluginWindow", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40));

	return Style;
}

I’ve pinpointed the error to the function FindPlugin(“MyPluginEditor”). I believe this returns a pointer to an empty plugin object, meaning that it failed to find the plugin called “MyPluginEditor”. When GetBaseDir() is called on this pointer, it throws the “assertion failed isValid()” error, since there is obviously no plugin object to get the base directory from.

This makes sense because with my setup, “MyPluginEditor” is no longer a plugin, it’s now a module within a plugin. So I just changed:

Style->SetContentRoot(IPluginManager::Get().FindPlugin("MyPluginEditor")->GetBaseDir() / TEXT("Resources"));

to :

Style->SetContentRoot(IPluginManager::Get().FindPlugin("MyPlugin")->GetBaseDir() / TEXT("Resources"));

Where MyPlugin is the name of the plugin.

This is a very niche problem so I don’t expect many people will encounter it, but just in case: this is the solution.

Best,
-S

1 Like