strange D-Bus interactions with gtk_dialog_run

Gnaural gnaural at users.sourceforge.net
Fri Nov 16 08:08:40 PST 2007


Using the "listen()" function in Matthew Johnson's
excellent D-Bus low-level API code here:
http://dbus.freedesktop.org/doc/dbus/libdbus-tutorial.html

I've been testing a very minimal drop-in D-Bus server
for use in my Gnaural program (basically just adding a
g_timeout_add() calling the listen() function every
second).

It seemed to work great, until I selected "Open File"
from Gnaural's menu -- which appeared to break the
server (clients could no longer connect). Gnaural just
continued on happily, though.

The example code is non-blocking, using
dbus_connection_read_write(conn, 0). Which wasn't
really what I wanted anyway, so I went ahead and
implemented a blocking approach, by spawning a gthread
that starts a loop along these lines:
 while (dbus_connection_read_write_dispatch
(gds_remote_connection, -1)) { }
approach.

With that, "Open File" totally freezes all GUI
features of the app (the Open File dialog and
Gnaural's  main window), HOWEVER, the D-Bus server is
still happily servicing clients and the sound thread
is also unaffected. Incidentally, I do no see any
significant CPU load during this freeze.

Looking in to it a bit more, I found that it was any
call to gtk_dialog_run() AFTER gtk_main() that caused
this behavior (FWIW, calling just before did not do
anything bad).

Incidentally, i did not see anything like this problem
in my earlier try at a D-Bus server using the
dbus-glib bindings [I only abandoned that server
because cross-compiling dbus-glib binding for Win32
isn't feasible].

Any ideas what I'm doing wrong? FWIW, the current
gthread code in these tests is a total hack -- no
mutex locking protection, just enough to launch and
forget the D-Bus server. But then, the D-Bus code was
breaking even when I was using the non-blocking
example (which didn't have a separate thread).

BTW, does this thread in any way relate?:
http://lists.freedesktop.org/archives/dbus/2005-April/002480.html

Thanks!




More information about the dbus mailing list