From 0789249ba4c05a965df2bdc27e26a1a4ab620f06 Mon Sep 17 00:00:00 2001 From: Dongsug Song Date: Fri, 5 Mar 2021 16:41:07 +0900 Subject: [PATCH] [NUI] Enable Window.ViewAdded event - Previously, Window.ViewAdded event was blocked by memory leak - This is enabled again by the request from Appium - This change has beend checked locally and there was no memory leak (normal) --- src/Tizen.NUI/src/public/BaseComponents/View.cs | 5 ++--- src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs | 2 +- src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs | 8 ++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 54c9aea..e967580 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -101,9 +101,8 @@ namespace Tizen.NUI.BaseComponents PositionUsesPivotPoint = false; } - //ToDo: this has memory leak and this is not used currently. will be fixed soon by using Event subscribing pattern. - //_onWindowSendEventCallback = SendViewAddedEventToWindow; - //this.OnWindowSignal().Connect(_onWindowSendEventCallback); + onWindowSendEventCallback = SendViewAddedEventToWindow; + this.OnWindowSignal().Connect(onWindowSendEventCallback); if (!shown) { diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index cfdcc47..d94024c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -56,7 +56,7 @@ namespace Tizen.NUI.BaseComponents private ResourcesLoadedCallbackType ResourcesLoadedCallback; private EventHandler backgroundResourceLoadedEventHandler; private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback; - + private OnWindowEventCallbackType onWindowSendEventCallback; private void SendViewAddedEventToWindow(IntPtr data) { // Unused parameter diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index 7e5672a..e6032e7 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1279,6 +1279,14 @@ namespace Tizen.NUI.BaseComponents backgroundResourceLoadedCallback = null; } + if (onWindowSendEventCallback != null) + { + ViewSignal signal = this.OnWindowSignal(); + signal?.Disconnect(onWindowSendEventCallback); + signal?.Dispose(); + onWindowSendEventCallback = null; + } + // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here. // Restore current CPtr. SwigCPtr = currentCPtr; -- 2.7.4