From 0bb3ee99f2f86d1c6235dae9418e8edb32254a57 Mon Sep 17 00:00:00 2001
From: dongsug-song <35130733+dongsug-song@users.noreply.github.com>
Date: Wed, 31 Jan 2018 17:56:21 +0900
Subject: [PATCH] [NUI] memory leak issue, rollback changes except View and
Layer (#104)
---
src/Tizen.NUI/src/internal/FrameBuffer.cs | 6 +-----
src/Tizen.NUI/src/internal/ViewWrapperImpl.cs | 6 +-----
src/Tizen.NUI/src/public/BaseComponents/TableView.cs | 12 ++----------
src/Tizen.NUI/src/public/FocusManager.cs | 18 +++---------------
src/Tizen.NUI/src/public/Renderer.cs | 18 +++---------------
src/Tizen.NUI/src/public/TextureSet.cs | 12 ++----------
src/Tizen.NUI/src/public/Touch.cs | 6 +-----
src/Tizen.NUI/src/public/UIComponents/Popup.cs | 18 +++---------------
8 files changed, 16 insertions(+), 80 deletions(-)
diff --git a/src/Tizen.NUI/src/internal/FrameBuffer.cs b/src/Tizen.NUI/src/internal/FrameBuffer.cs
index 085bdb1..648d0c2 100755
--- a/src/Tizen.NUI/src/internal/FrameBuffer.cs
+++ b/src/Tizen.NUI/src/internal/FrameBuffer.cs
@@ -99,12 +99,8 @@ namespace Tizen.NUI
public Texture GetColorTexture()
{
- //to fix memory leak issue, match the handle count with native side.
global::System.IntPtr cPtr = NDalicPINVOKE.FrameBuffer_GetColorTexture(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ Texture ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Texture;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/internal/ViewWrapperImpl.cs b/src/Tizen.NUI/src/internal/ViewWrapperImpl.cs
index 3c009a6..d145ce6 100755
--- a/src/Tizen.NUI/src/internal/ViewWrapperImpl.cs
+++ b/src/Tizen.NUI/src/internal/ViewWrapperImpl.cs
@@ -252,12 +252,8 @@ namespace Tizen.NUI
public VisualBase GetVisual(int index)
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicManualPINVOKE.ViewWrapperImpl_GetVisual(swigCPtr, index);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- VisualBase ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as VisualBase;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ VisualBase ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as VisualBase;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/public/BaseComponents/TableView.cs b/src/Tizen.NUI/src/public/BaseComponents/TableView.cs
index be2115c..8743ae1 100755
--- a/src/Tizen.NUI/src/public/BaseComponents/TableView.cs
+++ b/src/Tizen.NUI/src/public/BaseComponents/TableView.cs
@@ -379,12 +379,8 @@ namespace Tizen.NUI.BaseComponents
/// 3
public View GetChildAt(TableView.CellPosition position)
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicPINVOKE.TableView_GetChildAt(swigCPtr, TableView.CellPosition.getCPtr(position));
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -398,12 +394,8 @@ namespace Tizen.NUI.BaseComponents
/// 3
public View RemoveChildAt(TableView.CellPosition position)
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicPINVOKE.TableView_RemoveChildAt(swigCPtr, TableView.CellPosition.getCPtr(position));
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/public/FocusManager.cs b/src/Tizen.NUI/src/public/FocusManager.cs
index f8fd384..1982994 100755
--- a/src/Tizen.NUI/src/public/FocusManager.cs
+++ b/src/Tizen.NUI/src/public/FocusManager.cs
@@ -449,12 +449,8 @@ namespace Tizen.NUI
/// 3
public View GetCurrentFocusView()
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetCurrentFocusActor(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
return ret;
}
@@ -557,12 +553,8 @@ namespace Tizen.NUI
/// 3
public View GetFocusGroup(View view)
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetFocusGroup(swigCPtr, View.getCPtr(view));
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
return ret;
}
@@ -592,12 +584,8 @@ namespace Tizen.NUI
internal View GetFocusIndicatorView()
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetFocusIndicatorActor(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
return ret;
}
diff --git a/src/Tizen.NUI/src/public/Renderer.cs b/src/Tizen.NUI/src/public/Renderer.cs
index e345ddd..4e0320e 100755
--- a/src/Tizen.NUI/src/public/Renderer.cs
+++ b/src/Tizen.NUI/src/public/Renderer.cs
@@ -231,12 +231,8 @@ namespace Tizen.NUI
/// 3
public Geometry GetGeometry()
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicPINVOKE.Renderer_GetGeometry(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- Geometry ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Geometry;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ Geometry ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Geometry;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -272,12 +268,8 @@ namespace Tizen.NUI
/// 3
public TextureSet GetTextures()
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicPINVOKE.Renderer_GetTextures(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- TextureSet ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as TextureSet;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ TextureSet ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as TextureSet;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -301,12 +293,8 @@ namespace Tizen.NUI
/// 3
public Shader GetShader()
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicPINVOKE.Renderer_GetShader(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- Shader ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Shader;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ Shader ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Shader;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/public/TextureSet.cs b/src/Tizen.NUI/src/public/TextureSet.cs
index 949dece..91b6de6 100755
--- a/src/Tizen.NUI/src/public/TextureSet.cs
+++ b/src/Tizen.NUI/src/public/TextureSet.cs
@@ -104,12 +104,8 @@ namespace Tizen.NUI
/// 3
public Texture GetTexture(uint index)
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetTexture(swigCPtr, index);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ Texture ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Texture;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -135,12 +131,8 @@ namespace Tizen.NUI
/// 3
public Sampler GetSampler(uint index)
{
- //to fix memory leak issue, match the handle count with native side.
System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetSampler(swigCPtr, index);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- Sampler ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Sampler;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ Sampler ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Sampler;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/public/Touch.cs b/src/Tizen.NUI/src/public/Touch.cs
index 635c679..49e933d 100755
--- a/src/Tizen.NUI/src/public/Touch.cs
+++ b/src/Tizen.NUI/src/public/Touch.cs
@@ -165,12 +165,8 @@ namespace Tizen.NUI
/// 3
public View GetHitView(uint point)
{
- //to fix memory leak issue, match the handle count with native side.
global::System.IntPtr cPtr = NDalicPINVOKE.Touch_GetHitActor(swigCPtr, point);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
diff --git a/src/Tizen.NUI/src/public/UIComponents/Popup.cs b/src/Tizen.NUI/src/public/UIComponents/Popup.cs
index 1a557ee..0b81c5a 100755
--- a/src/Tizen.NUI/src/public/UIComponents/Popup.cs
+++ b/src/Tizen.NUI/src/public/UIComponents/Popup.cs
@@ -405,12 +405,8 @@ namespace Tizen.NUI.UIComponents
internal View GetTitle()
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicPINVOKE.Popup_GetTitle(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -429,12 +425,8 @@ namespace Tizen.NUI.UIComponents
internal View GetContent()
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicPINVOKE.Popup_GetContent(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
@@ -453,12 +445,8 @@ namespace Tizen.NUI.UIComponents
internal View GetFooter()
{
- //to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = NDalicPINVOKE.Popup_GetFooter(swigCPtr);
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View;
- NDalicPINVOKE.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
--
2.7.4