diff --git a/src/libvalent/device/valent-device-manager.c b/src/libvalent/device/valent-device-manager.c index 1da2375700..8ef7c6b366 100644 --- a/src/libvalent/device/valent-device-manager.c +++ b/src/libvalent/device/valent-device-manager.c @@ -612,11 +612,6 @@ valent_device_manager_save_state (ValentDeviceManager *self) g_assert (VALENT_IS_DEVICE_MANAGER (self)); - generator = g_object_new (JSON_TYPE_GENERATOR, - "pretty", TRUE, - "root", self->state, - NULL); - for (unsigned int i = 0, len = self->devices->len; i < len; i++) { ValentDevice *device = g_ptr_array_index (self->devices, i); @@ -629,6 +624,11 @@ valent_device_manager_save_state (ValentDeviceManager *self) } } + generator = g_object_new (JSON_TYPE_GENERATOR, + "pretty", TRUE, + "root", self->state, + NULL); + file = valent_context_get_cache_file (self->context, "devices.json"); if (!json_generator_to_file (generator, g_file_peek_path (file), &error)) g_warning ("%s(): %s", G_STRFUNC, error->message); diff --git a/src/plugins/lan/valent-lan-channel-service.c b/src/plugins/lan/valent-lan-channel-service.c index 1d6dea86bb..a5980a7ae7 100644 --- a/src/plugins/lan/valent-lan-channel-service.c +++ b/src/plugins/lan/valent-lan-channel-service.c @@ -72,10 +72,9 @@ on_channel_destroyed (ValentLanChannelService *self, g_assert (VALENT_IS_LAN_CHANNEL_SERVICE (self)); g_assert (VALENT_IS_LAN_CHANNEL (channel)); + valent_object_lock (VALENT_OBJECT (self)); certificate = valent_channel_get_certificate (VALENT_CHANNEL (channel)); device_id = valent_certificate_get_common_name (certificate); - - valent_object_lock (VALENT_OBJECT (self)); g_hash_table_remove (self->channels, device_id); valent_object_unlock (VALENT_OBJECT (self)); } @@ -130,7 +129,7 @@ valent_lan_channel_service_verify_channel (ValentLanChannelService *self, valent_object_lock (VALENT_OBJECT (self)); channel = g_hash_table_lookup (self->channels, device_id); - if (channel != NULL) + if (channel != NULL && !valent_object_in_destruction (VALENT_OBJECT (channel))) certificate = valent_channel_get_peer_certificate (VALENT_CHANNEL (channel)); valent_object_unlock (VALENT_OBJECT (self)); @@ -896,7 +895,9 @@ valent_lan_channel_service_channel (ValentChannelService *service, device_id = valent_certificate_get_common_name (peer_certificate); valent_object_lock (VALENT_OBJECT (service)); - g_hash_table_replace (self->channels, g_strdup (device_id), channel); + g_hash_table_replace (self->channels, + g_strdup (device_id), + g_object_ref (channel)); g_signal_connect_object (channel, "destroy", G_CALLBACK (on_channel_destroyed), @@ -1160,7 +1161,7 @@ valent_lan_channel_service_init (ValentLanChannelService *self) self->channels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - NULL); + g_object_unref); self->monitor = g_network_monitor_get_default (); } diff --git a/tests/extra/cppcheck.supp b/tests/extra/cppcheck.supp index 5b076930c3..e7aa8433fe 100644 --- a/tests/extra/cppcheck.supp +++ b/tests/extra/cppcheck.supp @@ -19,18 +19,10 @@ leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:787 leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:806 leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:810 -# src/plugins/battery/ -memleak:src/plugins/battery/valent-battery-gadget.c - -# src/plugins/pipewire/ -memleak:src/plugins/pipewire/valent-pipewire-mixer.c:698 - -# src/plugins/sms/ -leakNoVarFunctionCall:src/plugins/sms/valent-conversation-page.c:568 -leakNoVarFunctionCall:src/plugins/sms/valent-conversation-page.c:573 +# tests/plugins/bluez/ +memleak:tests/plugins/bluez/test-bluez-plugin.c:183 # tests/plugins/connectivity_report/ -memleak:src/plugins/connectivity_report/valent-connectivity_report-gadget.c:206 leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:258 leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:260 leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:262 @@ -40,25 +32,12 @@ leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:279 leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:281 -# tests/plugins/gnome/ -leakNoVarFunctionCall:src/plugins/gnome/valent-mutter-input.c:174 - -# tests/plugins/bluez/ -memleak:tests/plugins/bluez/test-bluez-plugin.c:183 - -# tests/plugins/fdo/ -leakNoVarFunctionCall:tests/plugins/fdo/test-fdo-notifications.c:122 -leakNoVarFunctionCall:tests/plugins/fdo/test-fdo-session.c:65 -memleak:tests/plugins/fdo/test-fdo-notifications.c:164 - -# tests/plugins/gtk/ -leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:115 -leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:117 -leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:119 - # tests/plugins/lan/ -memleak:src/plugins/lan/valent-lan-channel-service.c:544 -memleak:src/plugins/lan/valent-lan-channel-service.c:559 +memleak:src/plugins/lan/valent-lan-channel-service.c:543 +memleak:src/plugins/lan/valent-lan-channel-service.c:558 memleak:src/plugins/lan/valent-lan-dnssd.c:84 memleak:src/plugins/lan/valent-lan-dnssd.c:94 +# src/plugins/pipewire/ +memleak:src/plugins/pipewire/valent-pipewire-mixer.c:698 +