From 8901f407590f82db060dd1bb388dd80209356035 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Mon, 9 Nov 2020 16:30:18 +0900 Subject: [PATCH] Stop observing visuals when a control is destroyed Change-Id: I6c46f3090cfb8235ed0a081ab328d48c410f039e --- .../src/dali-toolkit/utc-Dali-Control.cpp | 25 ++++++++++++++++++++++ .../controls/control/control-data-impl.cpp | 10 +++++++++ 2 files changed, 35 insertions(+) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 396bab4..ddca23f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -1244,3 +1244,28 @@ int UtcDaliControlDoActionWhenNotStage(void) END_TEST; } + +int UtcDaliControlStopObservingVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "Test to stop observing a visual when a control is destroyed" ); + + Control control = Control::New(); + control[Actor::Property::SIZE] = Vector2( 200.f, 200.f ); + control[Control::Property::BACKGROUND] = "invalid.svg"; + + application.GetScene().Add( control ); + + application.SendNotification(); + application.Render(); + + // Delete control + control.Unparent(); + control.Reset(); + + // SVG rasterization may be finished after the control is deleted. + // Ensure it doesn't cause a crash. + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index df01b27..9182c1f 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -459,6 +459,16 @@ Control::Impl::Impl( Control& controlImpl ) Control::Impl::~Impl() { + for( auto&& iter : mVisuals ) + { + StopObservingVisual( iter->visual ); + } + + for( auto&& iter : mRemoveVisuals ) + { + StopObservingVisual( iter->visual ); + } + AccessibilityDeregister(); // All gesture detectors will be destroyed so no need to disconnect. delete mStartingPinchScale; -- 2.7.4