From 8e0de299e4d747078de7378f645ac22b4a165958 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Tue, 5 Aug 2014 11:33:52 +0200 Subject: [PATCH] generator: Set Owned to false when ownership of a parameter changes This fixes an issue where unref would get called too often because the ownership has changed when passing an instance to the native side. See https://github.com/mono/gtk-sharp/pull/112 for more details. --- generator/Parameter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generator/Parameter.cs b/generator/Parameter.cs index 02c0ad5c4..7c6016b50 100644 --- a/generator/Parameter.cs +++ b/generator/Parameter.cs @@ -290,6 +290,8 @@ namespace GtkSharp.Generation { return new string [] { gen.MarshalType + " native_" + CallName + ";" }; } else if (PassAs == "ref" && CSType != MarshalType) { return new string [] { gen.MarshalType + " native_" + CallName + " = (" + gen.MarshalType + ") " + CallName + ";" }; + } else if (gen is OpaqueGen && Owned) { + return new string [] { CallName + ".Owned = false;" }; } return new string [0];