libnm: fix assertion in NMClient checking for current main context

NMClient is strongly tied to the GMainContext with which it was created.
Several operations must only be called from within the context. There
was an assertion for that.

However, creating (and init_async()) should be allowed to call not
from within the GMainContext. So if the current context has no owner
(is not acquired), then it's also OK.

Fix the assertion for that.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
This commit is contained in:
Thomas Haller 2022-03-11 11:45:32 +01:00
parent 5dc9307a34
commit ae0cc9618c
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -764,7 +764,7 @@ _nm_client_set_property_sync_legacy(NMClient *self,
NMClientPrivate *_priv = NM_CLIENT_GET_PRIVATE(self); \
\
nm_assert(g_source_get_context(_source) == _priv->x_context); \
nm_assert(g_main_context_is_owner(_priv->x_context)); \
nm_assert(nm_g_main_context_can_acquire(_priv->x_context)); \
} \
} \
} \
@ -778,7 +778,7 @@ _nm_client_set_property_sync_legacy(NMClient *self,
\
nm_assert((g_main_context_get_thread_default() ?: g_main_context_default()) \
== _priv->x_context); \
nm_assert(g_main_context_is_owner(_priv->x_context)); \
nm_assert(nm_g_main_context_can_acquire(_priv->x_context)); \
} \
} \
G_STMT_END