atspi: remove property notification 50/256650/3
authorShinwoo Kim <cinoo.kim@samsung.com>
Thu, 8 Apr 2021 11:36:48 +0000 (20:36 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Mon, 12 Apr 2021 10:17:28 +0000 (19:17 +0900)
If a control registers and deregisters accessiblity repeatedly,
the number of notification becomes larger and larger. And it
makes system slower and slower.

This patch is removeing property notification, when a control
unregisters accessibility.

Change-Id: I99d4831c70aebe148031eba552756fb08f603bc6

automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/public-api/controls/control-impl.cpp

index bd8f3a4..f3d97a9 100644 (file)
@@ -98,6 +98,9 @@ int UtcDaliAccessibilityPushButtonStates(void)
 
   Dali::Accessibility::TestEnableSC( true );
 
+  /* add to scene and remove from scene to touch AccessibilityDeregister */
+  application.GetScene().Add( pushbutton );
+
   auto states = accessible->GetStates();
   DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::PRESSED ] ), false, TEST_LOCATION );
 
@@ -108,6 +111,9 @@ int UtcDaliAccessibilityPushButtonStates(void)
   states = accessible->GetStates();
   DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::PRESSED ] ), true, TEST_LOCATION );
 
+  /* add to scene and remove from scene to touch AccessibilityDeregister */
+  application.GetScene().Remove( pushbutton );
+
   Dali::Accessibility::TestEnableSC( false );
 
   END_TEST;
index 1c48bc1..070fa82 100644 (file)
@@ -487,7 +487,7 @@ Control::Impl::~Impl()
     StopObservingVisual(iter->visual);
   }
 
-  AccessibilityDeregister();
+  AccessibilityDeregister(false);
   // All gesture detectors will be destroyed so no need to disconnect.
   delete mStartingPinchScale;
 
@@ -1942,12 +1942,32 @@ void Control::Impl::AccessibilityRegister()
   }
 }
 
-void Control::Impl::AccessibilityDeregister()
+void Control::Impl::AccessibilityDeregister(bool remove)
 {
   if(accessibilityNotificationSet)
   {
+    accessibilityNotificationPosition.NotifySignal().Disconnect(&Control::Impl::PositionOrSizeChangedCallback);
+    if(remove)
+    {
+      mControlImpl.Self().RemovePropertyNotification(accessibilityNotificationPosition);
+    }
+    accessibilityNotificationPosition.Reset();
     accessibilityNotificationPosition = {};
+
+    accessibilityNotificationSize.NotifySignal().Disconnect(&Control::Impl::PositionOrSizeChangedCallback);
+    if(remove)
+    {
+      mControlImpl.Self().RemovePropertyNotification(accessibilityNotificationSize);
+    }
+    accessibilityNotificationSize.Reset();
     accessibilityNotificationSize     = {};
+
+    accessibilityNotificationCulled.NotifySignal().Disconnect(&Control::Impl::CulledChangedCallback);
+    if(remove)
+    {
+      mControlImpl.Self().RemovePropertyNotification(accessibilityNotificationCulled);
+    }
+    accessibilityNotificationCulled.Reset();
     accessibilityNotificationCulled   = {};
     accessibilityNotificationSet      = false;
   }
index 492461e..a3ab6c0 100644 (file)
@@ -544,7 +544,7 @@ public:
   Dali::Accessibility::Accessible*        GetAccessibilityObject();
 
   void AccessibilityRegister();
-  void AccessibilityDeregister();
+  void AccessibilityDeregister(bool remove);
 
   std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Actor)> accessibilityConstructor;
   std::unique_ptr<Dali::Accessibility::Accessible>                       accessibilityObject;
index 2c90452..62b1079 100644 (file)
@@ -605,7 +605,7 @@ void Control::OnSceneDisconnection()
 {
   if(Accessibility::IsUp())
   {
-    mImpl->AccessibilityDeregister();
+    mImpl->AccessibilityDeregister(true);
   }
   mImpl->OnSceneDisconnection();
 }