[Vala] how to avoid compile warnings with dbus
- From: con flatulence <conflatulence gmail com>
- To: vala-list gnome org
- Subject: [Vala] how to avoid compile warnings with dbus
- Date: Sun, 8 Jan 2012 00:18:05 +1100
Hello, I was playing with the dbus server example from the vala wiki* and
wanted to have a server with a constructor param, but when compiling there
is a warning (runs fine). Is there way to do this without compile warnings?
[DBus (name = "org.example.Demo")]
public class DemoServer : Object {
private int counter;
public int ping (string msg) {
stdout.printf ("%s, counter=%d\n", msg, this.counter);
return counter++;
}
public DemoServer(int initial_count) {
this.counter = initial_count;
}
}
[DBus (name = "org.example.DemoError")]
public errordomain DemoError { SOME_ERROR }
void main () {
var initial_count = 3;
Bus.own_name (BusType.SESSION, "org.example.Demo",
BusNameOwnerFlags.NONE,
(conn) => {
message("Bus acquired handler.");
try {
conn.register_object("/org/example/demo", new
DemoServer(initial_count));
} catch (IOError e) {
error(@"Could not register service: $(e.message)");
}
},
() => { message("Name aquired handler."); },
() => { error("Name lost handler."); }
);
new MainLoop ().run ();
}
[zach monica vala]$ valac --save-temps --pkg gio-2.0 dbus-server-arg.vala
/home/zach/misc/vala/dbus-server-arg.c: In function ‘_vala_main’:
/home/zach/misc/vala/dbus-server-arg.c:349:2: warning: passing argument 3
of ‘g_cclosure_new’ from incompatible pointer type [enabled by default]
/usr/include/glib-2.0/gobject/gclosure.h:195:11: note: expected
‘GClosureNotify’ but argument is of type ‘void (*)(struct Block1Data *)’
I'm using fedora 16, and vala from git commit 8fe20bf5500f
Looking at the C, I can see that block1_data_unref doesn't have the
GClosure* param of a GClosureNotify, adding a cast to GClosureNotify in the
C stops the warning, but I don't know if it's right. I'm not familiar with
GObject. How are the GClosure(s) created in the call to
g_bus_own_name_with_closures freed?
thanks
zach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]