From 7d1a12a14f667cd619dd0bc5f1df285b6aef9ce3 Mon Sep 17 00:00:00 2001 From: Yuriy Toporovskyy Date: Tue, 15 Jun 2021 18:33:44 -0400 Subject: [PATCH] Bug fix: crash after full screen preview due to dangling pointer --- Code/Sandbox/Editor/EditorViewportWidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index b02aafbe32..9ff38a34c1 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -1381,6 +1381,10 @@ void EditorViewportWidget::SetViewportId(int id) { CViewport::SetViewportId(id); + // Clear the cached debugdisplay pointer. we're about to delete that render viewport, and deleting the render + // viewport invalidates the debugdisplay. + m_debugDisplay = nullptr; + // First delete any existing layout // This also deletes any existing render viewport widget (since it will be added to the layout) // Below is the typical method of clearing a QLayout, see e.g. https://doc.qt.io/qt-5/qlayout.html#takeAt