[3.0] Fix crash in wayland
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / window-render-surface-ecore-wl.cpp
index 532c47f..40cd572 100644 (file)
@@ -23,7 +23,7 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <wl-types.h>
+#include <ecore-wl-types.h>
 #include <trigger-event.h>
 #include <gl/egl-implementation.h>
 #include <base/display-connection.h>
@@ -50,7 +50,8 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize,
                                           const std::string& name,
                                           bool isTransparent)
 : EcoreWlRenderSurface( positionSize, surface, name, isTransparent ),
-  mNeedToApproveDeiconify(false)
+  mEglWindow( NULL ),
+  mNeedToApproveDeiconify( false )
 {
   DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
   Init( surface );
@@ -58,6 +59,12 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize,
 
 WindowRenderSurface::~WindowRenderSurface()
 {
+  if( mEglWindow != NULL )
+  {
+    wl_egl_window_destroy(mEglWindow);
+    mEglWindow = NULL;
+  }
+
   if( mOwnSurface )
   {
     ecore_wl_window_free( mWlWindow );
@@ -123,8 +130,12 @@ void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
 
   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
   eglImpl.DestroySurface();
-  wl_egl_window_destroy(mEglWindow);
-  mEglWindow = NULL;
+
+  if( mEglWindow != NULL )
+  {
+    wl_egl_window_destroy(mEglWindow);
+    mEglWindow = NULL;
+  }
 }
 
 bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl )