[Tizen] forward dali-native exceptions to c# side
authordongsug.song <dongsug.song@samsung.com>
Mon, 14 Aug 2017 15:49:28 +0000 (00:49 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 14 Aug 2017 15:51:31 +0000 (00:51 +0900)
Change-Id: I60513cfed38abb5ecba13ddd418d9dad19c2cf81
Signed-off-by: dongsug.song <dongsug.song@samsung.com>
NUISamples/NUISamples/NUISamples.Tizen/examples/hello-world.cs
src/Tizen.NUI/src/internal/dotnetcore/AddedException.cs
src/Tizen.NUI/src/internal/dotnetcore/HandleRef.cs
src/Tizen.NUI/src/public/BaseHandle.cs

index faeb66f..d20b4db 100755 (executable)
@@ -16,6 +16,7 @@
 */
 
 using System;
+using System.Threading.Tasks;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 
@@ -58,12 +59,22 @@ namespace HelloWorldTest
             pointLabel.PointSize = 32.0f;
             window.Add(pointLabel);
 
+            Task.Factory.StartNew(() =>
+            {
+                try
+                {
             TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
             ellipsis.Size2D = new Size2D(100, 100);
             ellipsis.Position2D = new Position2D(10, 250);
             ellipsis.PointSize = 20.0f;
             ellipsis.Ellipsis = true;
             window.Add(ellipsis);
+                }
+                catch (Exception e)
+                {
+                    NUILog.Debug($"exception caught! e={e}");
+                }
+            }).Wait();
 
             TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
             autoScrollStopMode.Size2D = new Size2D(400, 100);
index 5e05865..a6acae7 100755 (executable)
@@ -1,54 +1,54 @@
-/** Copyright (c) 2017 Samsung Electronics Co., Ltd.\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*\r
-*/\r
-\r
-namespace System\r
-{\r
-    public class ApplicationException : Exception\r
-    {\r
-        public ApplicationException()\r
-        {\r
-            new global::System.ApplicationException();\r
-        }\r
-\r
-        public ApplicationException(string message)\r
-        {\r
-            new global::System.ApplicationException(message);\r
-        }\r
-\r
-        public ApplicationException(string message, Exception innerException)\r
-        {\r
-            new global::System.ApplicationException(message, innerException);\r
-        }\r
-    }\r
-\r
-    public class SystemException : Exception\r
-    {\r
-        public SystemException()\r
-        {\r
-            new global::System.SystemException();\r
-        }\r
-\r
-        public SystemException(string message)\r
-        {\r
-            new global::System.SystemException(message);\r
-        }\r
-\r
-        public SystemException(string message, Exception innerException)\r
-        {\r
-            new global::System.SystemException(message, innerException);\r
-        }\r
-    }\r
-}\r
+/** Copyright (c) 2017 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+namespace System
+{
+    public class ApplicationException : Exception
+    {
+        public ApplicationException(): base()
+        {
+            //new global::System.ApplicationException();
+        }
+
+        public ApplicationException(string message): base(message)
+        {
+            //new global::System.ApplicationException(message);
+        }
+
+        public ApplicationException(string message, Exception innerException): base(message, innerException)
+        {
+            //new global::System.ApplicationException(message, innerException);
+        }
+    }
+
+    public class SystemException : Exception
+    {
+        public SystemException(): base()
+        {
+            //new global::System.SystemException();
+        }
+
+        public SystemException(string message): base(message)
+        {
+            //new global::System.SystemException(message);
+        }
+
+        public SystemException(string message, Exception innerException): base(message, innerException)
+        {
+            //new global::System.SystemException(message, innerException);
+        }
+    }
+}
index c83d431..db34d4a 100755 (executable)
@@ -1,55 +1,55 @@
-// ==++==\r
-// \r
-//   Copyright (c) Microsoft Corporation.  All rights reserved.\r
-// \r
-// ==--==\r
-namespace System.Runtime.InteropServices\r
-{\r
-\r
-    using System;\r
-\r
-    [System.Runtime.InteropServices.ComVisible(true)]\r
-    public struct HandleRef\r
-    {\r
-\r
-        // ! Do not add or rearrange fields as the EE depends on this layout.\r
-        //------------------------------------------------------------------\r
-        internal Object m_wrapper;\r
-        internal IntPtr m_handle;\r
-        //------------------------------------------------------------------\r
-\r
-\r
-        public HandleRef(Object wrapper, IntPtr handle)\r
-        {\r
-            m_wrapper = wrapper;\r
-            m_handle = handle;\r
-        }\r
-\r
-        public Object Wrapper\r
-        {\r
-            get\r
-            {\r
-                return m_wrapper;\r
-            }\r
-        }\r
-\r
-        public IntPtr Handle\r
-        {\r
-            get\r
-            {\r
-                return m_handle;\r
-            }\r
-        }\r
-\r
-\r
-        public static explicit operator IntPtr(HandleRef value)\r
-        {\r
-            return value.m_handle;\r
-        }\r
-\r
-        public static IntPtr ToIntPtr(HandleRef value)\r
-        {\r
-            return value.m_handle;\r
-        }\r
-    }\r
-}\r
+// ==++==
+// 
+//   Copyright (c) Microsoft Corporation.  All rights reserved.
+// 
+// ==--==
+namespace System.Runtime.InteropServices
+{
+
+    using System;
+
+    [System.Runtime.InteropServices.ComVisible(true)]
+    public struct HandleRef
+    {
+
+        // ! Do not add or rearrange fields as the EE depends on this layout.
+        //------------------------------------------------------------------
+        internal Object m_wrapper;
+        internal IntPtr m_handle;
+        //------------------------------------------------------------------
+
+
+        public HandleRef(Object wrapper, IntPtr handle)
+        {
+            m_wrapper = wrapper;
+            m_handle = handle;
+        }
+
+        public Object Wrapper
+        {
+            get
+            {
+                return m_wrapper;
+            }
+        }
+
+        public IntPtr Handle
+        {
+            get
+            {
+                return m_handle;
+            }
+        }
+
+
+        public static explicit operator IntPtr(HandleRef value)
+        {
+            return value.m_handle;
+        }
+
+        public static IntPtr ToIntPtr(HandleRef value)
+        {
+            return value.m_handle;
+        }
+    }
+}
index c692895..4206215 100755 (executable)
@@ -25,12 +25,16 @@ namespace Tizen.NUI
 
         internal BaseHandle(global::System.IntPtr cPtr, bool cMemoryOwn)
         {
+            //to catch derived classes dali native exceptions
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
             _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));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             if (_registerMe)
             {
@@ -47,6 +51,7 @@ namespace Tizen.NUI
 
             // 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));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             if (_registerMe)
             {