dbus/mono Arguments.cs,1.3,1.4
Owen Fraser-Green
ow3n at pdx.freedesktop.org
Sun May 2 05:56:29 EST 2004
Update of /cvs/dbus/dbus/mono
In directory pdx:/tmp/cvs-serv22592/mono
Modified Files:
Arguments.cs
Log Message:
Handle empty iterators.
Index: Arguments.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Arguments.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/Arguments.cs 24 Mar 2004 13:15:20 -0000 1.3
+++ b/Arguments.cs 1 May 2004 19:56:27 -0000 1.4
@@ -181,15 +181,17 @@
string key = "";
// Iterate through the parameters getting the type codes to a string
- dbus_message_iter_init(message.RawMessage, iter);
+ bool empty = dbus_message_iter_init(message.RawMessage, iter);
- do {
- char code = (char) dbus_message_iter_get_arg_type(iter);
- if (code == '\0')
- return key;
-
- key += code;
- } while (dbus_message_iter_next(iter));
+ if (!empty) {
+ do {
+ char code = (char) dbus_message_iter_get_arg_type(iter);
+ if (code == '\0')
+ return key;
+
+ key += code;
+ } while (dbus_message_iter_next(iter));
+ }
Marshal.FreeCoTaskMem(iter);
@@ -219,6 +221,7 @@
{
private Arguments arguments;
private bool started = false;
+ private bool empty = false;
private IntPtr iter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
public ArgumentsEnumerator(Arguments arguments)
@@ -238,13 +241,13 @@
return dbus_message_iter_next(iter);
} else {
started = true;
- return true;
+ return !empty;
}
}
public void Reset()
{
- dbus_message_iter_init(arguments.message.RawMessage, iter);
+ empty = dbus_message_iter_init(arguments.message.RawMessage, iter);
started = false;
}
@@ -274,7 +277,7 @@
private extern static bool dbus_message_iter_next(IntPtr iter);
[DllImport("dbus-1")]
- private extern static void dbus_message_iter_init(IntPtr rawMessage, IntPtr iter);
+ private extern static bool dbus_message_iter_init(IntPtr rawMessage, IntPtr iter);
[DllImport("dbus-1")]
private extern static int dbus_message_iter_get_arg_type(IntPtr iter);
More information about the dbus-commit
mailing list