From 890e27b0a13ee384e9474b0d04d3d838ff4c568c Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 5 Dec 2024 10:30:25 -0300 Subject: [PATCH] Fix UI tests Fixed a crash accessing a nullptr native window running UI tests from CLI. Regression from 2e13559bbb211e79f5a031daa7b241a98b75895d --- src/ui/display.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/display.cpp b/src/ui/display.cpp index 0e2860580..8a9c10b7a 100644 --- a/src/ui/display.cpp +++ b/src/ui/display.cpp @@ -51,7 +51,10 @@ Display::Display(Display* parentDisplay, os::SurfaceRef Display::nativeSurface() const { - return base::AddRef(m_nativeWindow->surface()); + if (m_nativeWindow) + return base::AddRef(m_nativeWindow->surface()); + else + return nullptr; } void Display::addLayer(const UILayerRef& layer) @@ -76,6 +79,9 @@ void Display::removeLayer(const UILayerRef& layer) void Display::configureBackLayer() { const os::SurfaceRef displaySurface = nativeSurface(); + if (!displaySurface) + return; + UILayerRef layer = backLayer(); os::SurfaceRef layerSurface = layer->surface();