libmm-glib,location: build_locations() doesn't own the dictionary

Rework the build_locations() method so that it doesn't take ownership
of the input dictionary. This allows us reusing this method with
dictionaries for which ownership cannot be transferred.
This commit is contained in:
Aleksander Morgado
2021-06-24 10:44:50 +02:00
parent e1fbc1ccb7
commit 4e4cb6d66a

View File

@@ -583,8 +583,7 @@ build_locations (GVariant *dictionary,
return TRUE; return TRUE;
g_variant_iter_init (&iter, dictionary); g_variant_iter_init (&iter, dictionary);
while (!inner_error && while (!inner_error && g_variant_iter_next (&iter, "{uv}", &source, &value)) {
g_variant_iter_next (&iter, "{uv}", &source, &value)) {
switch (source) { switch (source) {
case MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI: case MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI:
if (location_3gpp) if (location_3gpp)
@@ -606,16 +605,12 @@ build_locations (GVariant *dictionary,
g_warn_if_reached (); g_warn_if_reached ();
break; break;
} }
g_variant_unref (value); g_variant_unref (value);
} }
g_variant_unref (dictionary);
if (inner_error) { if (inner_error) {
g_propagate_error (error, inner_error); g_propagate_error (error, inner_error);
g_prefix_error (error, g_prefix_error (error, "Couldn't build locations result: ");
"Couldn't build locations result: ");
return FALSE; return FALSE;
} }
@@ -656,7 +651,7 @@ mm_modem_location_get_full_finish (MMModemLocation *self,
MMLocationCdmaBs **location_cdma_bs, MMLocationCdmaBs **location_cdma_bs,
GError **error) GError **error)
{ {
GVariant *dictionary = NULL; g_autoptr(GVariant) dictionary = NULL;
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);
@@ -736,7 +731,7 @@ mm_modem_location_get_full_sync (MMModemLocation *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GVariant *dictionary = NULL; g_autoptr(GVariant) dictionary = NULL;
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);