Skip to content

Improve method binding #974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
improve ref counting
  • Loading branch information
koubaa committed Dec 3, 2019
commit 96fd89692a7ce74213e08fa6e70163f1dcc4530d
8 changes: 2 additions & 6 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,22 +941,18 @@ private static bool ToAction(IntPtr value, Type obType, out object result, bool
if (setError) {
SetConversionError(value, obType);
}
obj.Dispose();
return false;
}

Action action = () => {
PyObject py_action = new PyObject(value);
var py_args = new PyObject[0];
var py_result = py_action.Invoke(py_args);

//Discard the result since this is being converted to an Action
py_result.Dispose();
py_action.Dispose();
Runtime.XDecref(value);
};

Runtime.XIncref(value);
result = action;
obj.Dispose();
return true;
}

Expand Down