From: Shinwoo Kim Date: Wed, 6 Apr 2022 14:02:43 +0000 (+0900) Subject: [NUI] application: remove unnecessary reference count increments X-Git-Tag: accepted/tizen/unified/20231205.024657~1058 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61e8a573469f95cbd936e748728566c4b810ad5a;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] application: remove unnecessary reference count increments The GetWindow increases reference count of the Dali Window. So there was no chance to call the Window destructor. --- diff --git a/src/Tizen.NUI/src/internal/Application/Application.cs b/src/Tizen.NUI/src/internal/Application/Application.cs index 73430e0..b434edb 100755 --- a/src/Tizen.NUI/src/internal/Application/Application.cs +++ b/src/Tizen.NUI/src/internal/Application/Application.cs @@ -1266,7 +1266,18 @@ namespace Tizen.NUI return window; } - window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true); + var nativeWindow = Interop.Application.GetWindow(SwigCPtr); + window = Registry.GetManagedBaseHandleFromNativePtr(nativeWindow) as Window; + if (window != null) + { + HandleRef CPtr = new HandleRef(this, nativeWindow); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, IntPtr.Zero); + } + else + { + window = new Window(nativeWindow, true); + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return window; @@ -1302,7 +1313,7 @@ namespace Tizen.NUI List WindowList = new List(); for (uint i = 0; i < ListSize; ++i) { - Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window; + Window currWin = WindowList.GetInstanceSafely(Interop.Application.GetWindowsFromList(i)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); if (currWin != null) {