Fix crash issue when surface deleted before initialized 58/315058/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 24 Jul 2024 06:55:37 +0000 (15:55 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 24 Jul 2024 07:00:09 +0000 (16:00 +0900)
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 <eunkiki.hong@samsung.com>
dali/internal/window-system/common/window-render-surface.cpp

index 6b7fbbb..fa05aca 100644 (file)
@@ -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)