summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-15 00:06:29 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-15 00:06:29 -0300
commitfe8496cb6e24f43bde943190092aad89626771db (patch)
treed4ebe93ab5136202bb2c9d5461e87b7e15c6e539
parent2b71b630225c3ca5caee3f4500fe54d4c92000eb (diff)
csharp: More CA2000 fixes
Summary: For eldbus.Proxy.Send, as the native function takes ownership of the message, we Ref it so it can still be used afterwards. Ref T8423 Reviewers: brunobelo, felipealmeida, YOhoho Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8423 Differential Revision: https://phab.enlightenment.org/D10670
-rw-r--r--src/bindings/mono/efl_mono/efl_csharp_application.cs1
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_common.cs13
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_proxy.cs17
3 files changed, 23 insertions, 8 deletions
diff --git a/src/bindings/mono/efl_mono/efl_csharp_application.cs b/src/bindings/mono/efl_mono/efl_csharp_application.cs
index bab17c5d7d..4a936338cd 100644
--- a/src/bindings/mono/efl_mono/efl_csharp_application.cs
+++ b/src/bindings/mono/efl_mono/efl_csharp_application.cs
@@ -196,6 +196,7 @@ public abstract class Application
196 OnTerminate(); 196 OnTerminate();
197 }; 197 };
198 app.Begin(); 198 app.Begin();
199 command_line.Dispose();
199 Shutdown(); 200 Shutdown();
200 } 201 }
201} 202}
diff --git a/src/bindings/mono/eldbus_mono/eldbus_common.cs b/src/bindings/mono/eldbus_mono/eldbus_common.cs
index 1db6fe486b..ed32cbbc5c 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_common.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_common.cs
@@ -1481,8 +1481,8 @@ public static class Common
1481 return; 1481 return;
1482 } 1482 }
1483 1483
1484 eldbus.Message msg; 1484 eldbus.Message msg = null;
1485 eldbus.Pending pending; 1485 eldbus.Pending pending = null;
1486 1486
1487 try 1487 try
1488 { 1488 {
@@ -1492,6 +1492,11 @@ public static class Common
1492 catch (Exception e) 1492 catch (Exception e)
1493 { 1493 {
1494 Eina.Log.Error("Eldbus: could not convert Eldbus_Message_Cb parameters. Exception: " + e.ToString()); 1494 Eina.Log.Error("Eldbus: could not convert Eldbus_Message_Cb parameters. Exception: " + e.ToString());
1495
1496 if (msg != null)
1497 {
1498 msg.Dispose(); // CA2000
1499 }
1495 return; 1500 return;
1496 } 1501 }
1497 1502
@@ -1503,6 +1508,10 @@ public static class Common
1503 { 1508 {
1504 Eina.Log.Error("Eldbus: Eldbus_Message_Cb delegate error. Exception: " + e.ToString()); 1509 Eina.Log.Error("Eldbus: Eldbus_Message_Cb delegate error. Exception: " + e.ToString());
1505 } 1510 }
1511 finally
1512 {
1513 msg.Dispose(); // CA2000
1514 }
1506 } 1515 }
1507 1516
1508 private static Eldbus_Message_Cb message_cb_wrapper = null; 1517 private static Eldbus_Message_Cb message_cb_wrapper = null;
diff --git a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
index 03890ef004..8fd5921b8b 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
@@ -236,6 +236,10 @@ public class Proxy : IDisposable
236 throw new ArgumentNullException("msg"); 236 throw new ArgumentNullException("msg");
237 } 237 }
238 238
239 // Native send() takes ownership of the message. We ref here to keep the IDisposable
240 // behavior simpler and keeping the original object alive in case the user wants.
241 msg.Ref();
242
239 IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr(); 243 IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr();
240 IntPtr cb_data = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt); 244 IntPtr cb_data = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt);
241 245
@@ -265,14 +269,15 @@ public class Proxy : IDisposable
265 { 269 {
266 CheckHandle(); 270 CheckHandle();
267 271
268 var msg = NewMethodCall(member); 272 using (var msg = NewMethodCall(member))
269
270 foreach (BasicMessageArgument arg in args)
271 { 273 {
272 arg.AppendTo(msg); 274 foreach (BasicMessageArgument arg in args)
273 } 275 {
276 arg.AppendTo(msg);
277 }
274 278
275 return Send(msg, dlgt, timeout); 279 return Send(msg, dlgt, timeout);
280 }
276 } 281 }
277 282
278 eldbus.Pending Call(string member, params BasicMessageArgument[] args) 283 eldbus.Pending Call(string member, params BasicMessageArgument[] args)