Officially live, enjoy the knowledge :) !

Articles/Programming
Debugging Intermediate

Checking GEditor Before Using Editor-Only Code

Why editor compilation guards alone do not make GEditor safe to use in standalone mode, and where a null check helps.

Programming Tools C++ Intermediate Debugging
Articles C++Plugin Programming Intermediate C++ Plugin

WITH_EDITOR controls whether editor-related code is compiled. It does not guarantee that GEditor is available at runtime, including in a standalone session launched from an editor build.

Guard the editor instance

#if WITH_EDITOR
if (GEditor != nullptr)
{
    GEditor->SelectNone(true, true, false);
}
#endif

The compile-time guard excludes the operation from non-editor builds. The runtime check avoids dereferencing a null editor pointer when the code is included but an editor instance is unavailable.

Test the relevant editor, standalone, and packaged execution paths. A compile-time feature flag and a runtime object-lifetime check serve different purposes.