summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Shaw <joe@novell.com>2005-03-08 20:45:03 +0000
committerJohn Palmieri <johnp@remedyz.boston.redhat.com>2006-06-28 08:15:41 -0400
commit1abdda85d55d006800c8bd38697a64eca439589b (patch)
treefcdf1e116885936cdb1c0f0d6d31e9e7b4380f3d
parentc5fe0b2b763e36055748aee6ab34b46d5caf5c07 (diff)
2005-03-08 Joe Shaw <joeshaw@novell.com>
* dbus/dbus-connection.c (dbus_connection_send_with_reply): After we attach our pending call to the connection, unref it. Fixes a leak. * mono/Connection.cs (set_RawConnection): Disconnect our filter and match callbacks from the old connection and reconnect them to the new connection, if any. * mono/DBusType/Array.cs: "Code" is a static member, so don't use "this" to refer to it. Fix for stricter checking in Mono 1.1.4. * mono/DBusType/ObjectPath.cs (Append): Don't leak the object path that we pass into unmanaged code. * mono/DBusType/String.cs (Append): Don't leak the string that we pass into unmanged code.
-rw-r--r--mono/Connection.cs19
-rw-r--r--mono/DBusType/Array.cs2
-rw-r--r--mono/DBusType/ObjectPath.cs5
-rw-r--r--mono/DBusType/String.cs5
4 files changed, 28 insertions, 3 deletions
diff --git a/mono/Connection.cs b/mono/Connection.cs
index 699fee9..6abd7e8 100644
--- a/mono/Connection.cs
+++ b/mono/Connection.cs
@@ -171,6 +171,13 @@ namespace DBus
if (rawConnection != IntPtr.Zero)
{
+ // Remove our callbacks from this connection
+ foreach (DBusHandleMessageFunction func in this.filters)
+ dbus_connection_remove_filter (rawConnection, func, IntPtr.Zero);
+
+ foreach (string match_rule in this.matches)
+ dbus_bus_remove_match (rawConnection, match_rule, IntPtr.Zero);
+
// Get the reference to this
IntPtr rawThis = dbus_connection_get_data (rawConnection, Slot);
Debug.Assert (rawThis != IntPtr.Zero);
@@ -197,6 +204,18 @@ namespace DBus
rawThis = GCHandle.Alloc (this, GCHandleType.WeakTrackResurrection);
dbus_connection_set_data(rawConnection, Slot, (IntPtr) rawThis, IntPtr.Zero);
+
+ // Add the callbacks to this new connection
+ foreach (DBusHandleMessageFunction func in this.filters)
+ dbus_connection_add_filter (rawConnection, func, IntPtr.Zero, IntPtr.Zero);
+
+ foreach (string match_rule in this.matches)
+ dbus_bus_add_match (rawConnection, match_rule, IntPtr.Zero);
+ }
+ else
+ {
+ this.filters.Clear ();
+ this.matches.Clear ();
}
}
}
diff --git a/mono/DBusType/Array.cs b/mono/DBusType/Array.cs
index 7e46f73..ef001b9 100644
--- a/mono/DBusType/Array.cs
+++ b/mono/DBusType/Array.cs
@@ -59,7 +59,7 @@ namespace DBus.DBusType
IntPtr arrayIter = Marshal.AllocCoTaskMem (Arguments.DBusMessageIterSize);
if (!dbus_message_iter_open_container (iter,
- (int) this.Code,
+ (int) Code,
Arguments.GetCodeAsString (elementType),
arrayIter)) {
throw new ApplicationException("Failed to append array argument: " + val);
diff --git a/mono/DBusType/ObjectPath.cs b/mono/DBusType/ObjectPath.cs
index 01a21ca..4f064d5 100644
--- a/mono/DBusType/ObjectPath.cs
+++ b/mono/DBusType/ObjectPath.cs
@@ -52,7 +52,10 @@ namespace DBus.DBusType
{
IntPtr marshalVal = Marshal.StringToHGlobalAnsi (Path);
- if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
+ bool success = dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal);
+ Marshal.FreeHGlobal (marshalVal);
+
+ if (!success)
throw new ApplicationException("Failed to append OBJECT_PATH argument:" + val);
}
diff --git a/mono/DBusType/String.cs b/mono/DBusType/String.cs
index bf354ea..3b619cf 100644
--- a/mono/DBusType/String.cs
+++ b/mono/DBusType/String.cs
@@ -36,7 +36,10 @@ namespace DBus.DBusType
{
IntPtr marshalVal = Marshal.StringToHGlobalAnsi (val);
- if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
+ bool success = dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal);
+ Marshal.FreeHGlobal (marshalVal);
+
+ if (!success)
throw new ApplicationException("Failed to append STRING argument:" + val);
}