Hi,
There are two main issues here. Neither of these issues are present when using the deprecated ConstructObject()
which instructs you to use NewObject()
In my class derived from UObject:
if (HandlerClass && HandlerClass->ImplementsInterface(UModasInterface::StaticClass()))
{
UObject* Handler = NewObject<UObject>(this);
if (Handler)
{
IModasInterface::Execute_Construct(Handler);
}
}
By using NewObject
to create an instance I get this error stack and a ~1-2 second freeze when it occurs:
LogOutputDevice:Error: === Handled ensure: ===
LogOutputDevice:Error: Ensure condition failed: false [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2240]
LogOutputDevice:Error: Class which was marked abstract was trying to be loaded. It will be nulled out on save. None Object
LogOutputDevice:Error: Stack:
LogOutputDevice:Error: UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:200]
LogOutputDevice:Error: UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:233]
LogOutputDevice:Error: UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:360]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!StaticAllocateObjectErrorTests() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2240]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!StaticAllocateObject() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2306]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!StaticConstructObject_Internal() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:3265]
LogOutputDevice:Error: UE4Editor-Modas.dll!NewObject<UObject>() [d:\02_applications\ue_4.15\engine\source\runtime\coreuobject\public\uobject\uobjectglobals.h:1246]
LogOutputDevice:Error: UE4Editor-Modas.dll!UModasCore::Construct_Implementation() [d:\01_projects\04_marketplace\modas\modas\source\modas\private\modascore.cpp:37]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!UFunction::Invoke() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\class.cpp:4525]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!UObject::ProcessEvent() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1318]
LogOutputDevice:Error: UE4Editor-Modas.dll!IModasInterface::Execute_Construct()
LogOutputDevice:Error: UE4Editor-Modas.dll!UModasCore::Tick() [d:\01_projects\04_marketplace\modas\modas\source\modas\private\modascore.cpp:123]
LogOutputDevice:Error: UE4Editor-Engine.dll!FTickableGameObject::TickObjects() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\engine\private\leveltick.cpp:1182]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!UEditorEngine::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1666]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:391]
LogOutputDevice:Error: UE4Editor.exe!FEngineLoop::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3025]
LogOutputDevice:Error: UE4Editor.exe!GuardedMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launch.cpp:166]
LogOutputDevice:Error: UE4Editor.exe!GuardedMainWrapper() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
LogOutputDevice:Error: UE4Editor.exe!WinMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
LogOutputDevice:Error: UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
LogOutputDevice:Error: KERNEL32.DLL!0x0000000001452774
LogOutputDevice:Error: ntdll.dll!0x00000000020A0D61
Furthermore, by using NewObject
the editor will crash on an interface execute call:
Assertion failed: O->GetClass()->ImplementsInterface(UModasInterface::StaticClass()) [File:D:\01_Projects\04_Marketplace\Modas\Modas\Intermediate\Build\Win64\UE4Editor\Inc\Modas\Modas.generated.cpp] [Line: 31]