Timeouts should also be removed in the remove_timeout callback in
addition to the timeout_handler_free function. This is how dbus-glib
does it and it seems to prevent crashes in certain situations.
if (!handler)
return;
- g_source_remove(handler->id);
+ if (handler->id > 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
+
g_free(handler);
}
static void remove_timeout(DBusTimeout *timeout, void *data)
{
+ timeout_handler_t *handler;
+
+ handler = dbus_timeout_get_data(timeout);
+
+ if (!handler)
+ return;
+
+ if (handler->id > 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
}
static void timeout_toggled(DBusTimeout *timeout, void *data)