From dafb18678b932936848e7abc885779edaf87eab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Oct 2022 11:14:42 +0200 Subject: [PATCH] Use g_error() when library is not initalized This makes sure it still works when asserts are disabled. --- libfeedback/lfb-event.c | 24 ++++++++---------------- libfeedback/libfeedback.c | 12 ++++-------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/libfeedback/lfb-event.c b/libfeedback/lfb-event.c index 37bd7c7..4ba3d1f 100644 --- a/libfeedback/lfb-event.c +++ b/libfeedback/lfb-event.c @@ -415,10 +415,8 @@ lfb_event_trigger_feedback (LfbEvent *self, GError **error) g_return_val_if_fail (LFB_IS_EVENT (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before triggering events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before triggering events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), FALSE); @@ -466,10 +464,8 @@ lfb_event_trigger_feedback_async (LfbEvent *self, LfbGdbusFeedback *proxy; g_return_if_fail (LFB_IS_EVENT (self)); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before triggering events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before triggering events."); proxy = _lfb_get_proxy (); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy)); @@ -537,10 +533,8 @@ lfb_event_end_feedback (LfbEvent *self, GError **error) g_return_val_if_fail (LFB_IS_EVENT (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before ending events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy), FALSE); @@ -593,10 +587,8 @@ lfb_event_end_feedback_async (LfbEvent *self, LfbGdbusFeedback *proxy; g_return_if_fail (LFB_IS_EVENT (self)); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before ending events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy)); diff --git a/libfeedback/libfeedback.c b/libfeedback/libfeedback.c index 3855c72..76d8c6b 100644 --- a/libfeedback/libfeedback.c +++ b/libfeedback/libfeedback.c @@ -192,10 +192,8 @@ lfb_get_feedback_profile (void) { LfbGdbusFeedback *proxy; - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before getting the profile"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy), NULL); @@ -218,10 +216,8 @@ lfb_set_feedback_profile (const gchar *profile) { LfbGdbusFeedback *proxy; - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before setting the profile"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy));