[Tizen] Fixed many issues.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ViewImpl.cs
index 1f3da0a..aea5d39 100755 (executable)
@@ -616,12 +616,22 @@ namespace Tizen.NUI
 
         private void SwigDirectorOnChildAdd(global::System.IntPtr child)
         {
-            OnChildAdd(new View(child, false));
+            View view = Registry.GetManagedBaseHandleFromNativePtr(child) as View;
+
+            if (view)
+            {
+                OnChildAdd(view);
+            }
         }
 
         private void SwigDirectorOnChildRemove(global::System.IntPtr child)
         {
-            OnChildRemove(new View(child, false));
+            View view = Registry.GetManagedBaseHandleFromNativePtr(child) as View;
+
+            if (view)
+            {
+                OnChildRemove(view);
+            }
         }
 
         private void SwigDirectorOnPropertySet(int index, global::System.IntPtr propertyValue)
@@ -676,7 +686,12 @@ namespace Tizen.NUI
 
         private float SwigDirectorCalculateChildSize(global::System.IntPtr child, int dimension)
         {
-            return CalculateChildSize(new View(child, false), (DimensionType)dimension);
+            View view = Registry.GetManagedBaseHandleFromNativePtr(child) as View;
+            if (view)
+            {
+                return CalculateChildSize(view, (DimensionType)dimension);
+            }
+            return 0.0f;
         }
 
         private float SwigDirectorGetHeightForWidth(float width)
@@ -716,17 +731,29 @@ namespace Tizen.NUI
 
         private void SwigDirectorOnControlChildAdd(global::System.IntPtr child)
         {
-            OnControlChildAdd(new View(child, false));
+            View view = Registry.GetManagedBaseHandleFromNativePtr(child) as View;
+            if (view)
+            {
+                OnControlChildAdd(view);
+            }
         }
 
         private void SwigDirectorOnControlChildRemove(global::System.IntPtr child)
         {
-            OnControlChildRemove(new View(child, false));
+            View view = Registry.GetManagedBaseHandleFromNativePtr(child) as View;
+            if (view)
+            {
+                OnControlChildRemove(view);
+            }
         }
 
         private void SwigDirectorOnStyleChange(global::System.IntPtr styleManager, int change)
         {
-            OnStyleChange(new StyleManager(styleManager, true), (StyleChangeType)change);
+            StyleManager stManager = Registry.GetManagedBaseHandleFromNativePtr(styleManager) as StyleManager;
+            if (stManager)
+            {
+                OnStyleChange(stManager, (StyleChangeType)change);
+            }
         }
 
         private bool SwigDirectorOnAccessibilityActivated()
@@ -766,12 +793,12 @@ namespace Tizen.NUI
 
         private global::System.IntPtr SwigDirectorGetNextKeyboardFocusableView(global::System.IntPtr currentFocusedView, int direction, bool loopEnabled)
         {
-            return View.getCPtr(GetNextFocusableView(new View(currentFocusedView, true), (View.FocusDirection)direction, loopEnabled)).Handle;
+            return View.getCPtr(GetNextFocusableView(Registry.GetManagedBaseHandleFromNativePtr(currentFocusedView) as View, (View.FocusDirection)direction, loopEnabled)).Handle;
         }
 
         private void SwigDirectorOnKeyboardFocusChangeCommitted(global::System.IntPtr commitedFocusableView)
         {
-            OnFocusChangeCommitted(new View(commitedFocusableView, true));
+            OnFocusChangeCommitted(Registry.GetManagedBaseHandleFromNativePtr(commitedFocusableView) as View);
         }
 
         private bool SwigDirectorOnKeyboardEnter()