[M114] Avoid adding same EFlWindow to the dispatcher list more than once 29/297429/4
authorChandan Padhi <c.padhi@samsung.com>
Thu, 17 Aug 2023 14:58:49 +0000 (20:28 +0530)
committerChandan Padhi <c.padhi@samsung.com>
Wed, 23 Aug 2023 07:03:08 +0000 (07:03 +0000)
This commit ensures the following to fix the below CHECK failure.
1. EflWindow is added to the dispatcher list only once.
2. Previous EflEventHandler is deleted before creating a new one.

[0817/174640.034242:ERROR:observer_list.h(292)] Check failed: false.
Observers can only be added once!

Change-Id: Ibc8f06a5a76b774fd085ea7253fe44cb1dc9e1a9
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc

index 6bddf9d..95e5a97 100644 (file)
@@ -378,22 +378,30 @@ void EflWindow::ResetEventHandler() {
   delegate_->OnActivationChanged(false /*active*/);
   UpdateFocus(false);
   efl_event_handler_.reset();
+  PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
 }
 
 // Offscreen
 void EflWindow::SetNativeViewOffscreen(Evas_Object* native_view) {
-  native_view_ = native_view;
-  evas_ = evas_object_evas_get(native_view_);
-  ee_ = ecore_evas_ecore_evas_get(evas_);
+  if (native_view_ == native_view)
+    return;
 
-  if (EflWindow* window = window_manager_->GetWindow(native_view_)) {
+  if (EflWindow* window = window_manager_->GetWindow(native_view)) {
     // Sometimes multiple child aura windows will be created for the same RWHVA
     // which results in multiple EflWindows creation for the same native_view_.
     // If a native_view_ already had an associated EflWindow, then deregister it
     // and register the newly created one.
     window->ResetEventHandler();
-    window_manager_->RemoveWindow(native_view_);
+    window_manager_->RemoveWindow(native_view);
   }
+
+  ResetEventHandler();
+  window_manager_->RemoveWindow(native_view_);
+
+  native_view_ = native_view;
+  evas_ = evas_object_evas_get(native_view_);
+  ee_ = ecore_evas_ecore_evas_get(evas_);
+
   window_manager_->AddWindow(this, native_view_);
 
   InitializeEventHandler();