summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-launch-x11.c10
-rw-r--r--tools/dbus-launch.c18
-rw-r--r--tools/dbus-send.c6
3 files changed, 19 insertions, 15 deletions
diff --git a/tools/dbus-launch-x11.c b/tools/dbus-launch-x11.c
index 927d8634..442e9ba2 100644
--- a/tools/dbus-launch-x11.c
+++ b/tools/dbus-launch-x11.c
@@ -341,7 +341,7 @@ static Window
set_address_in_x11(char *address, pid_t pid)
{
char *current_address;
- Window wid;
+ Window wid = None;
unsigned long pid32; /* Xlib property functions want _long_ not 32-bit for format "32" */
/* lock the X11 display to make sure we're doing this atomically */
@@ -350,16 +350,14 @@ set_address_in_x11(char *address, pid_t pid)
if (!x11_get_address (&current_address, NULL, NULL))
{
/* error! */
- XUngrabServer (xdisplay);
- return None;
+ goto out;
}
if (current_address != NULL)
{
/* someone saved the address in the meantime */
- XUngrabServer (xdisplay);
free (current_address);
- return None;
+ goto out;
}
/* Create our window */
@@ -378,9 +376,11 @@ set_address_in_x11(char *address, pid_t pid)
/* Now grab the selection */
XSetSelectionOwner (xdisplay, selection_atom, wid, CurrentTime);
+ out:
/* Ungrab the server to let other people use it too */
XUngrabServer (xdisplay);
+ /* And make sure that the ungrab gets sent to X11 */
XFlush (xdisplay);
return wid;
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
index 6a10ffa3..216f7435 100644
--- a/tools/dbus-launch.c
+++ b/tools/dbus-launch.c
@@ -458,6 +458,17 @@ kill_bus_when_session_ends (void)
while (TRUE)
{
+#ifdef DBUS_BUILD_X11
+ /* Dump events on the floor, and let
+ * IO error handler run if we lose
+ * the X connection. It's important to
+ * run this before going into select() since
+ * we might have queued outgoing messages or
+ * events.
+ */
+ x11_handle_event ();
+#endif
+
FD_ZERO (&read_set);
FD_ZERO (&err_set);
@@ -472,7 +483,7 @@ kill_bus_when_session_ends (void)
FD_SET (x_fd, &read_set);
FD_SET (x_fd, &err_set);
}
-
+
select (MAX (tty_fd, x_fd) + 1,
&read_set, NULL, &err_set, NULL);
@@ -483,15 +494,12 @@ kill_bus_when_session_ends (void)
}
#ifdef DBUS_BUILD_X11
- /* Dump events on the floor, and let
- * IO error handler run if we lose
- * the X connection
+ /* Events will be processed before we select again
*/
if (x_fd >= 0)
verbose ("X fd condition reading = %d error = %d\n",
FD_ISSET (x_fd, &read_set),
FD_ISSET (x_fd, &err_set));
- x11_handle_event ();
#endif
if (tty_fd >= 0)
diff --git a/tools/dbus-send.c b/tools/dbus-send.c
index 66d0bcf9..407c0497 100644
--- a/tools/dbus-send.c
+++ b/tools/dbus-send.c
@@ -150,14 +150,10 @@ append_dict (DBusMessageIter *iter, int keytype, int valtype, const char *value)
while (val != NULL)
{
DBusMessageIter subiter;
- char sig[3];
- sig[0] = keytype;
- sig[1] = valtype;
- sig[2] = '\0';
dbus_message_iter_open_container (iter,
DBUS_TYPE_DICT_ENTRY,
- sig,
+ NULL,
&subiter);
append_arg (&subiter, keytype, val);