Material editor crashing (nullptr error in UE4EditorCore.dll) after adding custom MaterialExpression class

anonymous_user_ed54c79a
Mon, 10 Aug 2020 12:39:49 +0000
Asset Creation

After addition of a new C++ class under UMaterialExpression (i.e. a custom material node),
when I try to open any material editor, the UE4 editor crashes, reporting an error of reading nullptr in UE4EditorCore.dll.
This error disappeared after I removed the additional class. Therefore error source must be in the new class.
As no error is reported on creating default object of this class (when loading UE4Editor), probably the error is in header file, maybe in specifier macros (i.e. UCLASS() or UPROPERTY()).
In addition, the crash appears to occur before executing any code in the new header or source, i.e. no matter I set breakpoints on anywhere in header or source file, this error will occur without hitting any breakpoints.

Source code:

// MyExpression.h

#pragma once

#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "MaterialExpressionIO.h"
#include "Materials/MaterialExpression.h"
#include "MyExpression.generated.h"

UCLASS(MinimalAPI, collapsecategories, hidecategories = Object)
class UMyExpression : public UMaterialExpression
{
	GENERATED_UCLASS_BODY()

public:

	UPROPERTY()
	FExpressionInput Input;

	UPROPERTY(meta = (RequiredInput = "false", ToolTip = "Defaults to 2 if not specified"))
	FExpressionInput Strength;

#if WITH_EDITOR
	virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override;
	virtual void GetCaption(TArray<FString>& OutCaptions) const override;
#endif
};

1 post - 1 participant