shared/glib: prevent users to use g_cancellable_reset()

When handling a GCancellable, you make decisions based on when the cancelled
property of a GCancellable changes. Correctly handling a cancellable becoming
uncancelled again is really complicated, nor is it clear what it even means:
should the flipping be treated as cancellation or not? Probably if the
cancelled property gets reset, you already start aborting and there is
no way back. So, you would want that a cancellation is always handled.
But it's hard to implement that correctly, and it's odd to claim
something was cancelled, if g_cancellable_is_cancelled() doesn't agree
(anymore).

Avoid such problems by preventing users to call g_cancellable_reset().
This commit is contained in:
Thomas Haller 2020-04-26 15:46:53 +02:00
parent 32664c72a5
commit ee7fbc954e

View file

@ -622,4 +622,12 @@ g_hash_table_steal_extended (GHashTable *hash_table,
/*****************************************************************************/
__attribute__((__deprecated__("Don't use g_cancellable_reset(). Create a new cancellable instead.")))
void _nm_g_cancellable_reset (GCancellable *cancellable);
#undef g_cancellable_reset
#define g_cancellable_reset(cancellable) _nm_g_cancellable_reset(cancellable)
/*****************************************************************************/
#endif /* __NM_GLIB_H__ */