Fix Editor crash in test teardown calling set_view_pane_layout

If Atom isn't initialized and able to produce a ViewportContext, the Editor would crash. This attempts to make the initialization fail a bit more gracefully and fixes the crash in the cases I've tested.
This commit is contained in:
nvsickle
2021-04-21 17:42:02 -07:00
parent 104262e048
commit fb2ca8e02c
6 changed files with 49 additions and 12 deletions
@@ -43,9 +43,16 @@ namespace AtomToolsFramework
//! Creates a RenderViewportWidget.
//! Requires the Atom RPI to be initialized in order
//! to internally construct an RPI::ViewportContext.
explicit RenderViewportWidget(AzFramework::ViewportId id = AzFramework::InvalidViewportId, QWidget* parent = nullptr);
//! If initializeViewportContext is set to false, nothing will be displayed on-screen until InitiliazeViewportContext is called.
explicit RenderViewportWidget(QWidget* parent = nullptr, bool shouldInitializeViewportContext = true);
~RenderViewportWidget();
//! Initializes the underlying ViewportContext, if it hasn't already been.
//! If id is specified, the target ViewportContext will be overridden.
//! NOTE: ViewportContext IDs must be unique.
//! Returns true if the ViewportContext is available
//! (i.e. GetViewportContext will return a valid pointer).
bool InitializeViewportContext(AzFramework::ViewportId id = AzFramework::InvalidViewportId);
//! Gets the name associated with this viewport's ViewportContext.
//! This context name can be used to adjust the current Camera
//! independently of the underlying viewport.