Guard against creating a PreviewRenderer with uninitialized RPI. (#5708)
This was causing the SerializeContextTools executable to crash. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
This commit is contained in:
+9
-3
@@ -10,6 +10,7 @@
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <PreviewRenderer/PreviewRendererSystemComponent.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
@@ -53,10 +54,15 @@ namespace AtomToolsFramework
|
||||
AZ::TickBus::QueueFunction(
|
||||
[this]()
|
||||
{
|
||||
if (!m_previewRenderer)
|
||||
// Only create a preview renderer if the RPI interface is fully initialized. Otherwise the constructor will leave things
|
||||
// in a bad state that can lead to crashing.
|
||||
if (AZ::RPI::RPISystemInterface::Get()->IsInitialized())
|
||||
{
|
||||
m_previewRenderer.reset(aznew AtomToolsFramework::PreviewRenderer(
|
||||
"PreviewRendererSystemComponent Preview Scene", "PreviewRendererSystemComponent Preview Pipeline"));
|
||||
if (!m_previewRenderer)
|
||||
{
|
||||
m_previewRenderer.reset(aznew AtomToolsFramework::PreviewRenderer(
|
||||
"PreviewRendererSystemComponent Preview Scene", "PreviewRendererSystemComponent Preview Pipeline"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user