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.