From 4aeca604344d5b34ff97b32d7d54553f7cd26954 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 24 Jul 2024 15:55:37 +0900 Subject: [PATCH] Fix crash issue when surface deleted before initialized It is possible that delete WindowRenderSurface before call WindowRenderSurface::InitializeGraphics(). If then, mGraphics is nullptr. To avoid this case, let we check mGraphics validation before call mGraphics->DeleteSurface() Change-Id: Ie58d40754b6d935dfcbf2366f05c819666d5f028 Signed-off-by: Eunki, Hong --- .../window-system/common/window-render-surface.cpp | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/dali/internal/window-system/common/window-render-surface.cpp b/dali/internal/window-system/common/window-render-surface.cpp index 6b7fbbb..fa05aca 100644 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -352,11 +352,14 @@ void WindowRenderSurface::DestroySurface() { DALI_LOG_TRACE_METHOD(gWindowRenderSurfaceLogFilter); - DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: SurfaceId(%d) WinId (%d)\n", - mSurfaceId, - mWindowBase->GetNativeWindowId()); - mGraphics->DestroySurface(mSurfaceId); - mSurfaceId = Graphics::INVALID_SURFACE_ID; + if(DALI_LIKELY(mGraphics)) + { + DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: SurfaceId(%d) WinId (%d)\n", + mSurfaceId, + mWindowBase->GetNativeWindowId()); + mGraphics->DestroySurface(mSurfaceId); + mSurfaceId = Graphics::INVALID_SURFACE_ID; + } } bool WindowRenderSurface::ReplaceGraphicsSurface() @@ -375,7 +378,20 @@ bool WindowRenderSurface::ReplaceGraphicsSurface() height = mPositionSize.width; } - return mGraphics->ReplaceSurface(mSurfaceId, width, height); + if(DALI_LIKELY(mGraphics)) + { + DALI_LOG_RELEASE_INFO("WindowRenderSurface::ReplaceGraphicsSurface: SurfaceId(%d) WinId (%d), width(%d) height(%d)\n", + mSurfaceId, + mWindowBase->GetNativeWindowId(), + width, + height); + return mGraphics->ReplaceSurface(mSurfaceId, width, height); + } + else + { + DALI_LOG_ERROR("Graphics interface is not initialized yet."); + return false; + } } void WindowRenderSurface::UpdatePositionSize(Dali::PositionSize positionSize) -- 2.7.4