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


I’m trying to add a new module to a plugin I’m making. Basically I already wrote a runtime plugin and now I want to add an editor module so I can make a nice little UI to go with it. What I did was create a new blank UE4 project, then add a new plugin with the “Editor Standalone Window” preset, then copied the new plugin files to the plugin folder in my initial project.

The structure of my plugin folder now looks like this:

 ⤷ MyPlugin
      ⤷ Source
          ⤷ MyPlugin (runtime)
	          ⤷ Private
              ⤷ Public
          ⤷ MyPluginEditor (editor)
	          ⤷ Private
	          ⤷ Public

Then I edited the .uplugin file to add the new module to the “Modules” list. The project compiles fine in visual studio, and looking at the logs I don’t think there’s any issue with compiling. However when I launch the UE4 project, it just crashes with the following message :

Assertion failed: IsValid() [File:C:\Program Files\Epic Games\UE_4.26\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]

It launches correctly when I remove the module from the .uproject file, so the problem has to be with the new module. But as I mentionned the code comes straight from the “Editor Standalone Window” preset. So all i can think of is there’s something I need to change in the editor module’s Build.cs file. I just don’t know what. Any help?

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.


did u solved it ?

Hello there. I have exactly the same problem with a plugin i downloaded for my UE 4 (here is the plugin: myo-ue4/ at master · getnamo/myo-ue4 · GitHub). It doesn’t have an “Editor Section” and i can’t find a script like that you mensioned above. Do you have any idea?

Run it in debugger, and look at the crash trace when it asserts. It should give you some clue as to what’s causing it.

Hi there, sorry for the late response, but if you read the last update I posted on this thread you’ll find my solution.

Hi there, sorry for the late response, but if you read the last update I posted on this thread you’ll find my solution