Fix null dereference in widget viewer dali
[platform/core/uifw/widget-viewer-dali.git] / internal / widget_view / widget_view_impl.cpp
index 7c2f44b..d3d5295 100644 (file)
@@ -126,20 +126,22 @@ static void OnSurfaceUpdate( struct tizen_remote_surface* surface, wl_buffer* bu
 {
   Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
 
-  if( widgetView && !widgetView->IsWidgetImageView() )
+  if( widgetView )
   {
-    tizen_remote_surface_transfer_visibility( surface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
+    if( !widgetView->IsWidgetImageView() )
+    {
+      tizen_remote_surface_transfer_visibility( surface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
 
-    widgetView->CreateWidgetImageView();
-    widgetView->ConnectSignal( surface );
-    ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, OnKeyDown, surface );
-    ecore_event_handler_add( ECORE_EVENT_KEY_UP, OnKeyUp, surface );
+      widgetView->CreateWidgetImageView();
+      widgetView->ConnectSignal( surface );
+      ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, OnKeyDown, surface );
+      ecore_event_handler_add( ECORE_EVENT_KEY_UP, OnKeyUp, surface );
+    }
 
+    //get tbm surface from buffer
+    tbm_surface_h tbmSurface = static_cast< tbm_surface_h >( wl_buffer_get_user_data( buffer ) );
+    widgetView->UpdateImageSource( tbmSurface );
   }
-
-  //get tbm surface from buffer
-  tbm_surface_h tbmSurface = static_cast< tbm_surface_h >( wl_buffer_get_user_data( buffer ) );
-  widgetView->UpdateImageSource( tbmSurface );
 }
 
 static void OnSurfaceMissing( struct tizen_remote_surface* surface, void* data )