From: Umar Date: Tue, 18 Jul 2017 13:28:43 +0000 (+0100) Subject: [Tizen] Temporary Fix to return the Layer as a View when Parent is a Layer. X-Git-Tag: submit/trunk/20170823.075128~91^2~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f9a67850c746f16018b5a12284e2523cc297e20;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Tizen] Temporary Fix to return the Layer as a View when Parent is a Layer. Change-Id: I0e0805dd542bbae3f32d7e047bc7792ec37e1d79 --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 100800a..61ac23b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -2119,7 +2119,7 @@ namespace Tizen.NUI.BaseComponents return ret; } - internal View GetParent() + /*internal View GetParent() { IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr); @@ -2128,6 +2128,26 @@ namespace Tizen.NUI.BaseComponents if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; + }*/ + + internal View GetParent() + { + View ret; + IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr); + + BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr); + + if(basehandle is Layer) + { + View ret2 = new View(cPtr,false); + return ret2; + } + + ret = basehandle as View; + + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } internal void SetParentOrigin(Vector3 origin) diff --git a/src/Tizen.NUI/src/public/BaseHandle.cs b/src/Tizen.NUI/src/public/BaseHandle.cs index d14f943..e0d7ecc 100755 --- a/src/Tizen.NUI/src/public/BaseHandle.cs +++ b/src/Tizen.NUI/src/public/BaseHandle.cs @@ -21,22 +21,26 @@ namespace Tizen.NUI { private global::System.Runtime.InteropServices.HandleRef swigCPtr; protected bool swigCMemOwn; + private bool _registerMe; internal BaseHandle(global::System.IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; + _registerMe = swigCMemOwn = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); // using copy constructor to create another native handle so Registry.Unregister works fine. swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.new_BaseHandle__SWIG_2(swigCPtr)); - // Register this instance of BaseHandle in the registry. - Registry.Register(this); + if (_registerMe) + { + // Register this instance of BaseHandle in the registry. + Registry.Register(this); + } } internal BaseHandle(global::System.IntPtr cPtr) { - swigCMemOwn = true; + _registerMe = swigCMemOwn = true; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); // Register this instance of BaseHandle in the registry. @@ -101,7 +105,10 @@ namespace Tizen.NUI //because the execution order of Finalizes is non-deterministic. //Unreference this instance from Registry. - Registry.Unregister(this); + if (_registerMe) + { + Registry.Unregister(this); + } if (swigCPtr.Handle != global::System.IntPtr.Zero) { diff --git a/src/Tizen.NUI/src/public/Window.cs b/src/Tizen.NUI/src/public/Window.cs index 7a610fd..8520ee2 100755 --- a/src/Tizen.NUI/src/public/Window.cs +++ b/src/Tizen.NUI/src/public/Window.cs @@ -29,6 +29,7 @@ namespace Tizen.NUI { private global::System.Runtime.InteropServices.HandleRef swigCPtr; private global::System.Runtime.InteropServices.HandleRef stageCPtr; + private Layer _rootLayer; internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn) { @@ -564,9 +565,12 @@ namespace Tizen.NUI internal Layer GetRootLayer() { - Layer ret = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true); + if (_rootLayer == null) + _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true); + + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + return _rootLayer; } internal void SetBackgroundColor(Vector4 color)