From ebe359bc46d9bb6c3a8a92f005b096c83e73b0a8 Mon Sep 17 00:00:00 2001 From: Chungryeol Lim Date: Thu, 18 Jan 2018 13:21:22 +0900 Subject: [PATCH] [ElmSharp] fix svace issue (#42) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add an optional extended description… --- src/ElmSharp/ElmSharp/GenItemClass.cs | 4 ++-- src/ElmSharp/ElmSharp/GestureLayer.cs | 7 +++++-- src/ElmSharp/ElmSharp/Image.cs | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ElmSharp/ElmSharp/GenItemClass.cs b/src/ElmSharp/ElmSharp/GenItemClass.cs index de05212..bf2c4ca 100755 --- a/src/ElmSharp/ElmSharp/GenItemClass.cs +++ b/src/ElmSharp/ElmSharp/GenItemClass.cs @@ -217,8 +217,8 @@ namespace ElmSharp void EvasObjectDeleted(object sender, EventArgs e) { - IntPtr handle = (sender as EvasObject).Handle; - s_HandleToEvasObject.Remove(handle); + if(sender is EvasObject evasObject) + s_HandleToEvasObject.Remove(evasObject); } IntPtr GetReusableContentCallback(IntPtr data, IntPtr obj, IntPtr part, IntPtr old) diff --git a/src/ElmSharp/ElmSharp/GestureLayer.cs b/src/ElmSharp/ElmSharp/GestureLayer.cs index 6209ea6..c748fec 100644 --- a/src/ElmSharp/ElmSharp/GestureLayer.cs +++ b/src/ElmSharp/ElmSharp/GestureLayer.cs @@ -559,11 +559,14 @@ namespace ElmSharp // thanks to the fact that we never remove item from _handlers, we don't need a lock here if (handlerIndex < 0 || handlerIndex >= _handlers.Count) return; - Action action = _handlers[handlerIndex].Action; + + var currentHandler = _handlers[handlerIndex]; + Action action = currentHandler.Action; if (action == null) return; + // the interpretation of the event_info struct pointer depends on the GestureType - switch (_handlers[handlerIndex].Type) + switch (currentHandler.Type) { case GestureType.Tap: case GestureType.LongTap: diff --git a/src/ElmSharp/ElmSharp/Image.cs b/src/ElmSharp/ElmSharp/Image.cs index da69b82..ce8aa23 100644 --- a/src/ElmSharp/ElmSharp/Image.cs +++ b/src/ElmSharp/ElmSharp/Image.cs @@ -618,24 +618,24 @@ namespace ElmSharp } }; - MemoryStream memstream = new MemoryStream(); - await stream.CopyToAsync(memstream); - - unsafe + using (MemoryStream memstream = new MemoryStream()) { - byte[] dataArr = memstream.ToArray(); - fixed (byte* data = &dataArr[0]) + await stream.CopyToAsync(memstream); + + unsafe { - bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero); - if (!ret) + byte[] dataArr = memstream.ToArray(); + fixed (byte* data = &dataArr[0]) { - return false; + bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero); + if (!ret) + { + return false; + } } } } - memstream.Dispose(); - return await tcs.Task; } -- 2.7.4