Fix the crash while replacing the surface 42/193542/2
authorRichard Huang <r.huang@samsung.com>
Wed, 21 Nov 2018 18:24:28 +0000 (18:24 +0000)
committerRichard Huang <r.huang@samsung.com>
Thu, 22 Nov 2018 11:13:08 +0000 (11:13 +0000)
Change-Id: I65d4d76be4d801b44759ad4dbd60c6cb468791ee

dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp

index 05b60f9..c39903f 100755 (executable)
@@ -500,9 +500,7 @@ void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& newSurface )
   newDefaultWindow.nativeWindow = nativeWindow;
   newDefaultWindow.surface = &newSurface;
 
-  // Must delete the old Window first before replacing it with the new one
   WindowPane oldDefaultWindow = mWindowFrame.front();
-  oldDefaultWindow.surface->DestroySurface();
 
   // Update WindowFrame
   std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
@@ -514,6 +512,9 @@ void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& newSurface )
 
   // This method blocks until the render thread has completed the replace.
   mThreadController->ReplaceSurface( newDefaultWindow.surface );
+
+  // Must delete the old Window only after the render thread has completed the replace
+  oldDefaultWindow.surface->DestroySurface();
 }
 
 RenderSurface& Adaptor::GetSurface() const
index 2727430..cac09c5 100644 (file)
@@ -361,8 +361,11 @@ bool WindowRenderSurface::PreRender( bool resizingSurface )
   }
 
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
-  auto mGLES = eglGraphics->GetGlesInterface();
-  mGLES.PreRender();
+  if ( eglGraphics )
+  {
+    GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+    mGLES.PreRender();
+  }
 
   return true;
 }
@@ -371,39 +374,42 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b
 {
   // Inform the gl implementation that rendering has finished before informing the surface
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
-  auto mGLES = eglGraphics->GetGlesInterface();
-  mGLES.PostRender();
-
-  if( renderToFbo )
+  if ( eglGraphics )
   {
-    mGLES.Flush();
-    mGLES.Finish();
-  }
-  else
-  {
-    if( resizingSurface )
+    GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+    mGLES.PostRender();
+
+    if( renderToFbo )
     {
-      if( !mRotationFinished )
+      mGLES.Flush();
+      mGLES.Finish();
+    }
+    else
+    {
+      if( resizingSurface )
       {
-        DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
+        if( !mRotationFinished )
+        {
+          DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
 
-        mRotationTrigger->Trigger();
+          mRotationTrigger->Trigger();
 
-        if( mThreadSynchronization )
-        {
-          // Wait until the event-thread complete the rotation event processing
-          mThreadSynchronization->PostRenderWaitForCompletion();
+          if( mThreadSynchronization )
+          {
+            // Wait until the event-thread complete the rotation event processing
+            mThreadSynchronization->PostRenderWaitForCompletion();
+          }
         }
       }
     }
-  }
 
-  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-  eglImpl.SwapBuffers();
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    eglImpl.SwapBuffers();
 
-  if( mRenderNotification )
-  {
-    mRenderNotification->Trigger();
+    if( mRenderNotification )
+    {
+      mRenderNotification->Trigger();
+    }
   }
 }
 
index dd454f4..e019b0a 100644 (file)
@@ -54,6 +54,7 @@ Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, fals
 NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent )
 : mPosition( positionSize ),
   mRenderNotification( NULL ),
+  mGraphics( NULL ),
   mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
   mTbmFormat( isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888 ),
   mOwnSurface( false ),
@@ -210,9 +211,12 @@ bool NativeRenderSurfaceEcoreWl::PreRender( bool )
 void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
 {
   auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
-  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+  if ( eglGraphics )
+  {
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
-  eglImpl.SwapBuffers();
+    eglImpl.SwapBuffers();
+  }
 
   if( mThreadSynchronization )
   {