Fix memory leak while doing drag&drop with Debug Draw in use

#1723
This commit is contained in:
Wojtek Figat
2023-11-06 17:18:20 +01:00
parent e7b1fce3eb
commit ae85a94261
2 changed files with 19 additions and 0 deletions

View File

@@ -8,6 +8,18 @@
#include "Engine/Scripting/ManagedCLR/MDomain.h"
#include "Engine/Engine/Engine.h"
#include "Engine/Platform/Platform.h"
#if USE_EDITOR
#if !COMPILE_WITH_DEBUG_DRAW
#define COMPILE_WITH_DEBUG_DRAW 1
#define COMPILE_WITH_DEBUG_DRAW_HACK
#endif
#include "Engine/Debug/DebugDraw.h"
#ifdef COMPILE_WITH_DEBUG_DRAW_HACK
#undef COMPILE_WITH_DEBUG_DRAW_HACK
#undef COMPILE_WITH_DEBUG_DRAW
#define COMPILE_WITH_DEBUG_DRAW 0
#endif
#endif
/// <summary>
/// Async DoDragDrop helper (used for rendering frames during main thread stall).
@@ -23,6 +35,10 @@ public:
Scripting::GetScriptsDomain()->Dispatch();
while (Platform::AtomicRead(&ExitFlag) == 0)
{
#if USE_EDITOR
// Flush any single-frame shapes to prevent memory leaking (eg. via terrain collision debug during scene drawing with PhysicsColliders or PhysicsDebug flag)
DebugDraw::UpdateContext(nullptr, 0.0f);
#endif
Engine::OnDraw();
Platform::Sleep(20);
}