diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-28 18:15:19 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-29 15:13:31 +0400 |
commit | 36139c1de43390a2a6ca2ab900a68d2c815577b7 (patch) | |
tree | 7695a7d1b5e4aeb9c2c8bfbbcbfaa105fc5357e5 /main/src | |
parent | f3f939700eb1fc8ea5b4a26ddd609a9e586e7b4d (diff) |
[MacDev] Work around a bug when creating NSData objects
The current code throws an exception if the source array is of length
zero, so work around that until it's fixed.
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.PlistEditor/PListObject.cs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.PlistEditor/PListObject.cs b/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.PlistEditor/PListObject.cs index 6c81aeab13..876ccff561 100644 --- a/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.PlistEditor/PListObject.cs +++ b/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.PlistEditor/PListObject.cs @@ -756,6 +756,8 @@ namespace MonoDevelop.MacDev.PlistEditor public class PData : PValueObject<byte[]> { + static readonly byte[] Empty = new byte [0]; + public override string TypeString { get { return GettextCatalog.GetString ("Data"); @@ -764,10 +766,15 @@ namespace MonoDevelop.MacDev.PlistEditor public override NSObject Convert () { - return NSData.FromArray (Value); + // Work around a bug in NSData.FromArray as it cannot (currently) handle + // zero length arrays + if (Value.Length == 0) + return new NSData (); + else + return NSData.FromArray (Value); } - public PData (byte[] value) : base(value) + public PData (byte[] value) : base(value ?? Empty) { } @@ -779,7 +786,7 @@ namespace MonoDevelop.MacDev.PlistEditor public override void RenderValue (CustomPropertiesWidget widget, CellRendererCombo renderer) { renderer.Sensitive = false; - renderer.Text = string.Format ("byte[{0}]", Value != null ? Value.Length : 0); + renderer.Text = string.Format ("byte[{0}]", Value.Length); } } |