[Xfce4-commits] [apps/xfce4-volumed-pulse] 54/62: Improve error handling
noreply at xfce.org
noreply at xfce.org
Thu Sep 8 10:33:16 CEST 2016
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-volumed-pulse.
commit 8fff66196d49f48234c001eb6d3b2792d5827817
Author: Lionel Le Folgoc <lionel at lefolgoc.net>
Date: Fri May 25 21:23:55 2012 +0200
Improve error handling
---
src/main.c | 9 ++++++---
src/xvd_data_types.h | 3 ---
src/xvd_notify.c | 10 +++++-----
src/xvd_xfconf.c | 13 ++++++++-----
src/xvd_xfconf.h | 2 +-
5 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/main.c b/src/main.c
index 8cfda49..4f7ca0d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -100,7 +100,6 @@ xvd_instance_init(XvdInstance *i)
i->pa_main_loop = NULL;
i->pulse_context = NULL;
i->sink_index = -1;
- i->error = NULL;
i->chan = NULL;
i->loop = NULL;
#ifdef HAVE_LIBNOTIFY
@@ -162,14 +161,18 @@ main(gint argc, gchar **argv)
xvd_keys_init (Inst);
/* Xfconf init */
- xvd_xfconf_init (Inst);
+ if (!xvd_xfconf_init (Inst))
+ {
+ xvd_shutdown ();
+ return EXIT_FAILURE;
+ }
/* Pulse init */
if (!xvd_open_pulse (Inst))
{
g_warning ("Unable to initialize pulseaudio support, quitting");
xvd_shutdown ();
- return 1;
+ return EXIT_FAILURE;
}
xvd_xfconf_get_vol_step (Inst);
diff --git a/src/xvd_data_types.h b/src/xvd_data_types.h
index ca9bf68..41f2101 100644
--- a/src/xvd_data_types.h
+++ b/src/xvd_data_types.h
@@ -58,10 +58,7 @@ typedef struct {
int mute;
/* Xfconf vars */
- GError *error;
XfconfChannel *chan;
-
- /* Volume vars */
guint vol_step;
#ifdef HAVE_LIBNOTIFY
diff --git a/src/xvd_notify.c b/src/xvd_notify.c
index c340bc2..c70117e 100644
--- a/src/xvd_notify.c
+++ b/src/xvd_notify.c
@@ -34,7 +34,8 @@ xvd_notify_notification(XvdInstance *Inst,
gchar* icon,
gint value)
{
- gchar* title = NULL;
+ GError* error = NULL;
+ gchar* title = NULL;
if ((icon != NULL) && (g_strcmp0(icon, "audio-volume-muted") == 0)) {
// TRANSLATORS: this is the body of the ATK interface of the volume notifications. This is the case when volume is muted
@@ -61,11 +62,10 @@ xvd_notify_notification(XvdInstance *Inst,
"");
}
- Inst->error = NULL;
- if (!notify_notification_show (Inst->notification, &Inst->error))
+ if (!notify_notification_show (Inst->notification, &error))
{
- g_warning ("Error while sending notification : %s\n", Inst->error->message);
- g_error_free (Inst->error);
+ g_warning ("Error while sending notification : %s\n", error->message);
+ g_error_free (error);
}
}
diff --git a/src/xvd_xfconf.c b/src/xvd_xfconf.c
index 1c9319f..b1409df 100644
--- a/src/xvd_xfconf.c
+++ b/src/xvd_xfconf.c
@@ -41,17 +41,20 @@ _xvd_xfconf_handle_changes(XfconfChannel *re_channel,
}
}
-void
+gboolean
xvd_xfconf_init(XvdInstance *Inst)
{
- if (FALSE == xfconf_init (&Inst->error)) {
- g_warning ("%s%s\n", "Couldn't initialize xfconf : ", Inst->error->message);
- g_error_free (Inst->error);
- exit (EXIT_FAILURE);
+ GError *err = NULL;
+
+ if (!xfconf_init (&err)) {
+ g_warning ("%s%s\n", "Couldn't initialize xfconf: ", err->message);
+ g_error_free (err);
+ return FALSE;
}
Inst->chan = xfconf_channel_get (XFCONF_MIXER_CHANNEL_NAME);
g_signal_connect (G_OBJECT (Inst->chan), "property-changed", G_CALLBACK (_xvd_xfconf_handle_changes), Inst);
+ return TRUE;
}
void
diff --git a/src/xvd_xfconf.h b/src/xvd_xfconf.h
index aa60e37..2841111 100644
--- a/src/xvd_xfconf.h
+++ b/src/xvd_xfconf.h
@@ -23,7 +23,7 @@
#include "xvd_data_types.h"
-void
+gboolean
xvd_xfconf_init(XvdInstance *Inst);
void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list