/soc/2013/ankitkv/gobjectification: c176dbc958f0: Made error han...
Ankit Vani
a at nevitus.org
Sat Sep 7 16:59:20 EDT 2013
Changeset: c176dbc958f0fa5a45790251a47c5a0eeb2192d7
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-08 02:29 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c176dbc958f0
Description:
Made error handling better on protocol addition
diffstat:
libpurple/protocols.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diffs (42 lines):
diff --git a/libpurple/protocols.c b/libpurple/protocols.c
--- a/libpurple/protocols.c
+++ b/libpurple/protocols.c
@@ -769,27 +769,26 @@ purple_protocols_add(GType protocol_type
{
PurpleProtocol *protocol;
- g_return_val_if_fail(protocol_type != G_TYPE_INVALID &&
- protocol_type != G_TYPE_NONE, NULL);
-
- protocol = g_object_new(protocol_type, NULL);
-
- if (!PURPLE_IS_PROTOCOL(protocol)) {
+ if (protocol_type == G_TYPE_INVALID) {
g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0,
- _("Protocol type does not inherit PurpleProtocol"));
-
- g_object_unref(protocol);
+ _("Protocol type is not registered"));
return NULL;
}
- if (!PURPLE_IS_PROTOCOL_INTERFACE(protocol)) {
+ if (!g_type_is_a(protocol_type, PURPLE_TYPE_PROTOCOL)) {
+ g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0,
+ _("Protocol type does not inherit PurpleProtocol"));
+ return NULL;
+ }
+
+ if (!g_type_is_a(protocol_type, PURPLE_TYPE_PROTOCOL_INTERFACE)) {
g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0,
_("Protocol does not implement PurpleProtocolInterface"));
-
- g_object_unref(protocol);
return NULL;
}
+ protocol = g_object_new(protocol_type, NULL);
+
if (!purple_protocol_get_id(protocol)) {
g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0,
_("Protocol does not provide an ID"));
More information about the Commits
mailing list