From: Seungkeun Lee Date: Wed, 6 Apr 2016 06:54:08 +0000 (+0900) Subject: Bundle - Add Factory Method X-Git-Tag: submit/trunk/20170823.075128~121^2~180^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a99c6441d749945578ab7ad6eccf41a6be61533;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Bundle - Add Factory Method - Add Factory Method for Retained bundle - Add Constructor parameter for checking ownership Change-Id: I365c7c18fca50eb2d29c3e65b800ad670f40b837 --- diff --git a/Tizen.Applications/Interop/Interop.Bundle.cs b/Tizen.Applications/Interop/Interop.Bundle.cs old mode 100644 new mode 100755 index cb8d11c..995442e --- a/Tizen.Applications/Interop/Interop.Bundle.cs +++ b/Tizen.Applications/Interop/Interop.Bundle.cs @@ -50,6 +50,9 @@ internal static partial class Interop [DllImport(Libraries.Bundle, EntryPoint = "bundle_foreach")] internal static extern void Foreach(IntPtr handle, Iterator iterator, IntPtr userData); + [DllImport(Libraries.Bundle, EntryPoint = "bundle_dup")] + internal static extern IntPtr Clone(IntPtr handle); + internal static class UnsafeCode { internal static unsafe int AddItem(IntPtr handle, string key, byte[] value, int offset, int count) diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs index af25363..3d9563b 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs @@ -118,9 +118,8 @@ namespace Tizen.Applications.Messages } _messageCallBack = (int localPortId, string remoteAppId, string remotePortName, bool trusted, IntPtr message, IntPtr userData) => { - MessageReceivedEventArgs args = new MessageReceivedEventArgs() - { - Message = new Bundle(message) + MessageReceivedEventArgs args = new MessageReceivedEventArgs() { + Message = Bundle.MakeRetainedBundle(message) }; if (!String.IsNullOrEmpty(remotePortName) && !String.IsNullOrEmpty(remoteAppId)) diff --git a/Tizen.Applications/Tizen.Applications/Application.cs b/Tizen.Applications/Tizen.Applications/Application.cs index a9b653f..5bfdcf0 100755 --- a/Tizen.Applications/Tizen.Applications/Application.cs +++ b/Tizen.Applications/Tizen.Applications/Application.cs @@ -167,6 +167,7 @@ namespace Tizen.Applications string value = b.GetItem(Interop.AppEvent.EventKeys.LanguageSet); OnLocaleChanged(new LocaleChangedEventArgs { Locale = value }); } + b.Dispose(); } } } diff --git a/Tizen.Applications/Tizen.Applications/Bundle.cs b/Tizen.Applications/Tizen.Applications/Bundle.cs old mode 100644 new mode 100755 index ec94b9c..4a3a614 --- a/Tizen.Applications/Tizen.Applications/Bundle.cs +++ b/Tizen.Applications/Tizen.Applications/Bundle.cs @@ -35,12 +35,19 @@ namespace Tizen.Applications _keys = new HashSet(); } - internal Bundle(IntPtr handle) + static internal Bundle MakeRetainedBundle(IntPtr handle) + { + IntPtr clonedHandle = Interop.Bundle.Clone(handle); + return new Bundle(clonedHandle, true); + } + + internal Bundle(IntPtr handle, bool ownership = false) { if (handle != IntPtr.Zero) { _handle = handle; - _disposed = true; + if (!ownership) + _disposed = true; _keys = new HashSet(); Interop.Bundle.Iterator iterator = (string key, int type, IntPtr keyval, IntPtr userData) => {