DBus signals now work correctly on different buses simultaneously.
[GB.DBUS] * BUG: Use one watcher by bus, not one for all buses.
This commit is contained in:
parent
bf48f40f5c
commit
a2183117ff
2 changed files with 28 additions and 8 deletions
|
@ -1,8 +1,8 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.9.90
|
||||
# Compiled with Gambas 3.10.90
|
||||
Title=gb.dbus
|
||||
Startup=MMain
|
||||
Version=3.9.90
|
||||
Version=3.10.90
|
||||
VersionFile=1
|
||||
Component=gb.dbus
|
||||
TabSize=2
|
||||
|
|
|
@ -42,8 +42,6 @@ typedef
|
|||
|
||||
bool DBUS_Debug = FALSE;
|
||||
|
||||
static int _watch_count = 0;
|
||||
|
||||
static void handle_message(int fd, int type, DBusConnection *connection)
|
||||
{
|
||||
//fprintf(stdout, "handle_message\n");
|
||||
|
@ -1276,15 +1274,32 @@ static bool get_socket(DBusConnection *connection, int *socket)
|
|||
|
||||
bool DBUS_watch(DBusConnection *connection, bool on)
|
||||
{
|
||||
intptr_t count;
|
||||
int socket;
|
||||
static dbus_int32_t slot;
|
||||
|
||||
if (!dbus_connection_allocate_data_slot(&slot))
|
||||
{
|
||||
GB.Error("Unable to allocate DBusConnection data slot");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (get_socket(connection, &socket))
|
||||
return TRUE;
|
||||
|
||||
count = (intptr_t)dbus_connection_get_data(connection, slot);
|
||||
|
||||
if (on)
|
||||
{
|
||||
if (_watch_count == 0)
|
||||
if (count == 0)
|
||||
{
|
||||
count++;
|
||||
if (!dbus_connection_set_data(connection, slot, (void *)count, NULL))
|
||||
{
|
||||
GB.Error("Unable to increment watch count");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!dbus_connection_add_filter(connection, filter_func, NULL, NULL))
|
||||
{
|
||||
GB.Error("Unable to watch the DBus connection");
|
||||
|
@ -1297,12 +1312,17 @@ bool DBUS_watch(DBusConnection *connection, bool on)
|
|||
GB.Watch(socket, GB_WATCH_READ, (void *)handle_message, (intptr_t)connection);
|
||||
check_message(connection);
|
||||
}
|
||||
_watch_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_watch_count--;
|
||||
if (_watch_count == 0)
|
||||
count--;
|
||||
if (!dbus_connection_set_data(connection, slot, (void *)count, NULL))
|
||||
{
|
||||
GB.Error("Unable to decrement watch count");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (DBUS_Debug)
|
||||
fprintf(stderr, "gb.dbus: stop watching connection\n");
|
||||
|
|
Loading…
Reference in a new issue