Thanks. I’m surprised that something in my code is making the editor crash and not load. Why would some code in my project, where a null pointer is checked for, cause the Unreal Editor to crash? Is there a way to program safer to keep the editor from crashing? Is there a safe mode for the editor to load the editor with a generic empty project or something to give me a chance to change your project using the graphical editor?
Thank you for your help. :-). I’m surprised that even something that is checked for a null pointer is causing the editor to crash on loading. Is there a way to develop my code to make sure the editor loads? Is there a way to load the editor in safe mode that will load the editor for a project with minimal editor settings to make changes graphically?
if (NewWidgetClass != nullptr)
says "if NuewWidgetClass is not null, then execute the following code. Because StartingWidgetClass is never set, this call fails because NewWidgetClass is in fact null. When you try to call Load() on your GameWidget object, it was never created which is what causes the null reference crash.
Is this a bug because I think that the code you’re referring to is auto-generated by Unreal.
This is not a bug. The code I’m referring to was added to the MainGameMode.cpp file in the custom ChangeMenuWidget() function.
How did you find the error? Is there some special way to detect Unreal Engine’s problems with the way I write code? I keep running into the same issue of my editor crashing on loading even though compiling in my C++ editor says there are no errors. The only error I get is the very vague error writing to memory error that doesn’t tell me anything. I am guessing my new issue is some kind of special Unreal Editor error that only causes Unreal to crash. It doesn’t seem to matter if clean the make files and completely rebuild. Is there a special error log that tracks Unreal Engine’s warnings or errors that my C++ editor doesn’t catch? Can I set a flag to write to some kind of special log so I can fix my own errors?
Visual Studio will catch any issue that causes the compile to fail, not necessarily an issue in how the logic of the code functions. The issue in this case was a null reference; while the code was correct as it was written, attempting to use it causes issues with the object being referenced doesn’t exist. There is no special log for errors.
As for finding the error itself, I ran through Visual Studio debug mode and caused the crash to occur with pointed to ScoreText inside the UGameWidget::Load() function. Following functions calls (“what is calling UGameWidget::Load()”) I found AMainGameMode::BeginPlay() calls ChangeMenuWidget() before calling Load(). This is where I found the if (NewWidgetClass != nullptr)
and checked in the editor what the value was set to.
Okay. I don’t have visual studio though. I can’t use it either because I only use Ubuntu 16 as my OS. Is there a way to duplicate this error catching with any other linux C++ IDE like CodeLite? When I try to run the project from the IDE, I get errors about needing a visual context.
When you run the project through the IDE, it will attempt to launch the editor. If you don’t have a visual interface, the editor may not be able to launch.