From 1270d45d91aed5b67a861bf9bcbbd498dde3ac5b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 6 Dec 2021 17:40:09 +0100 Subject: [PATCH] Fix DBusClient._removeMatch() Reset the reference count before awaiting the RemoveMatch() D-Bus call to prevent that a reference goes missing if _addMatch() increases the reference count during the await. Related issue: #293 --- lib/src/dbus_client.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/dbus_client.dart b/lib/src/dbus_client.dart index 7c74eba..f6052a4 100644 --- a/lib/src/dbus_client.dart +++ b/lib/src/dbus_client.dart @@ -872,6 +872,7 @@ class DBusClient { } if (count == 1) { + _matchRules.remove(rule); if (!_socketClosed) { await callMethod( destination: 'org.freedesktop.DBus', @@ -881,7 +882,6 @@ class DBusClient { values: [DBusString(rule)], replySignature: DBusSignature('')); } - _matchRules.remove(rule); } else { _matchRules[rule] = count - 1; }