Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when opening animation blueprint #8

Open
iznaut opened this issue Jan 5, 2023 · 1 comment
Open

Crash when opening animation blueprint #8

iznaut opened this issue Jan 5, 2023 · 1 comment

Comments

@iznaut
Copy link

iznaut commented Jan 5, 2023

When opening an animation blueprint with this plugin enabled, UE4 will crash.

UE4Editor_ElgEditorScripting!UElgEditorContext_LevelEditor::HandleEditorModeEnter() [E:\P4NoGoblin\NG3Game\Plugins\ElgEditorScripting\Source\ElgEditorScripting\Private\EditorContexts\ElgEditorContext_LevelEditor.cpp:203]

The third line of this function in ElgEditorContext_LevelEditor.cpp was the problem:

void UElgEditorContext_LevelEditor::HandleEditorModeEnter(const FEditorModeID& ModeID)
{	
	FText oldName = CurrentEditorMode;
	FEdMode* mode = GLevelEditorModeTools().GetActiveMode(ModeID);
	CurrentEditorMode = mode->GetModeInfo().Name;
	OnEnterMode.Broadcast(CurrentEditorMode);
	if (!oldName.EqualTo(CurrentEditorMode)) {
		OnEditorModeChanged.Broadcast(CurrentEditorMode);
	}
}

My colleague was able to fix it by simply doing a check to make sure mode != NULL, so there's a workaround, but I thought I would report here so it could be properly fixed in the source.

top of the callstack was FName triggering an access violation, the crash is on the line where we're assigning a FName from a function that can return null, so I did a quick null check on the function before doing anything else

@igagnidze
Copy link

Thx for this, I got the 4.27 version and this was happening there too. It needs to be handled for both HandleEditorModeEnter and HandleEditorModeExit or the crash happens when closing animbp (and potentially some other editors like Niagara or Cascade) as well.

Here's the code if anyone wants to just copy/paste it (replace the existing code)

void UElgEditorContext_LevelEditor::HandleEditorModeEnter(const FEditorModeID& ModeID)
{	
	FText oldName = CurrentEditorMode;
	FEdMode* mode = GLevelEditorModeTools().GetActiveMode(ModeID);
	if(mode != nullptr){
		CurrentEditorMode = mode->GetModeInfo().Name;
		OnEnterMode.Broadcast(CurrentEditorMode);
		if (!oldName.EqualTo(CurrentEditorMode)) {
			OnEditorModeChanged.Broadcast(CurrentEditorMode);
		}
	}
}

void UElgEditorContext_LevelEditor::HandleEditorModeExit(const FEditorModeID& ModeID)
{
	FEdMode* mode = GLevelEditorModeTools().GetActiveMode(ModeID);
	if(mode != nullptr){
		OnExitMode.Broadcast(mode->GetModeInfo().Name);
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants