aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-05 13:36:48 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-05 13:36:48 -0300
commit0e55612280baca435ceaec3e67cbd24c79ff88f0 (patch)
tree84cd6063d136bf17a182b98fc84b19664096b659
parentefl_mono: efl_unrefs are functioning properly (diff)
downloadefl-devs/vitorsousa/csharp_end_error_fix.tar.gz
efl_mono: avoid C# making many handles for event delegates, so we can unregister themdevs/vitorsousa/csharp_end_error_fix
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh11
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs11
2 files changed, 12 insertions, 10 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index bec470efef..c2c885ec3e 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -472,7 +472,7 @@ struct klass
return true;
if (cls.get_all_events().size() > 0)
- if (!as_generator(scope_tab << visibility << "Dictionary<(IntPtr desc, object evtDelegate), Efl.EventCb> eoEvents = new Dictionary<(IntPtr desc, object evtDelegate), Efl.EventCb>();\n"
+ if (!as_generator(scope_tab << visibility << "Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)> eoEvents = new Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)>();\n"
<< scope_tab << visibility << "readonly object eventLock = new object();\n")
.generate(sink, attributes::unused, context))
return false;
@@ -667,13 +667,14 @@ struct klass
<< scope_tab << scope_tab << scope_tab << "return;\n"
<< scope_tab << scope_tab << "}\n\n"
- << scope_tab << scope_tab << "if (!Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evtCaller, IntPtr.Zero))\n"
+ << scope_tab << scope_tab << "IntPtr evtCallerPtr = Marshal.GetFunctionPointerForDelegate(evtCaller);\n"
+ << scope_tab << scope_tab << "if (!Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evtCallerPtr, IntPtr.Zero))\n"
<< scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << "return;\n"
<< scope_tab << scope_tab << "}\n\n"
- << scope_tab << scope_tab << "eoEvents[(desc, evtDelegate)] = evtCaller;\n"
+ << scope_tab << scope_tab << "eoEvents[(desc, evtDelegate)] = (evtCallerPtr, evtCaller);\n"
<< scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
<< scope_tab << "}\n\n"
@@ -692,10 +693,10 @@ struct klass
<< scope_tab << scope_tab << "}\n\n"
<< scope_tab << scope_tab << "var evtPair = (desc, evtDelegate);\n"
- << scope_tab << scope_tab << "if (eoEvents.TryGetValue(evtPair, out var evtCaller))\n"
+ << scope_tab << scope_tab << "if (eoEvents.TryGetValue(evtPair, out var caller))\n"
<< scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << "if (!Efl.Eo.Globals.efl_event_callback_del(handle, desc, evtCaller, IntPtr.Zero))\n"
+ << scope_tab << scope_tab << scope_tab << "if (!Efl.Eo.Globals.efl_event_callback_del(handle, desc, caller.evtCallerPtr, IntPtr.Zero))\n"
<< scope_tab << scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "return;\n"
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 77e3cfd75a..efec393d8e 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -175,10 +175,10 @@ public class Globals {
[DllImport(efl.Libs.Evil)] public static extern IntPtr dlerror();
[DllImport(efl.Libs.Eo)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
- efl_event_callback_priority_add(IntPtr obj, IntPtr desc, short priority, Efl.EventCb cb, IntPtr data);
+ efl_event_callback_priority_add(IntPtr obj, IntPtr desc, short priority, IntPtr cb, IntPtr data);
[DllImport(efl.Libs.Eo)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
- efl_event_callback_del(IntPtr obj, IntPtr desc, Efl.EventCb cb, IntPtr data);
+ efl_event_callback_del(IntPtr obj, IntPtr desc, IntPtr cb, IntPtr data);
[DllImport(efl.Libs.Eo)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
efl_event_callback_call(IntPtr obj, IntPtr desc, IntPtr event_info);
@@ -509,17 +509,18 @@ public class Globals {
try
{
GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr);
- var eoEvents = gcHandle.Target as Dictionary<(IntPtr desc, object evtDelegate), Efl.EventCb>;
+ var eoEvents = gcHandle.Target as Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)>;
if (eoEvents == null)
{
+ Eina.Log.Error($"Invalid event dictionary [GCHandle pointer: {gcHandlePtr}]");
return;
}
foreach (var item in eoEvents)
{
- if (!efl_event_callback_del(obj, item.Key.desc, item.Value, IntPtr.Zero))
+ if (!efl_event_callback_del(obj, item.Key.desc, item.Value.evtCallerPtr, IntPtr.Zero))
{
- Eina.Log.Error($"Failed to remove event proxy for event {item.Key.desc}");
+ Eina.Log.Error($"Failed to remove event proxy for event {item.Key.desc} [cb: {item.Value.evtCallerPtr}]");
}
}
}