Commit d2f8a2ba authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Yet another improvement for C# wrapper

parent 1d865de8
......@@ -133,6 +133,25 @@ namespace Linphone
{
if (ptr == IntPtr.Zero) return null;
IntPtr objPtr = belle_sip_object_data_get(ptr, "cs_obj");
if (objPtr != IntPtr.Zero)
{
T obj = null;
GCHandle handle = GCHandle.FromIntPtr(objPtr);
if (handle.IsAllocated)
{
obj = (T)handle.Target;
}
if (obj == null)
{
//Console.WriteLine("Handle target is null " + handle.Target);
objPtr = IntPtr.Zero;
}
else
{
//Console.WriteLine("Using existing " + obj.ToString());
return obj;
}
}
if (objPtr == IntPtr.Zero)
{
T obj = new T();
......@@ -147,14 +166,8 @@ namespace Linphone
objPtr = GCHandle.ToIntPtr(handle);
belle_sip_object_data_set(ptr, "cs_obj", objPtr, onDataDestroyed);
return obj;
}
else
{
GCHandle handle = GCHandle.FromIntPtr(objPtr);
T obj = (T)handle.Target;
//Console.WriteLine("Using existing " + obj.ToString());
return obj;
}
return null;
}
internal static IEnumerable<string> MarshalStringArray(IntPtr arrayPtr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment