Use g_return_val_if_fail() for developer-only messages

Replaced several usages of GError with g_return_val_if_fail() for
developer-only messages. As additional value, it also removes those
messages from the list to translate, simplifying translator's work a
bit.

https://bugzilla.gnome.org/show_bug.cgi?id=569017
This commit is contained in:
Ihar Hrachyshka 2013-10-11 23:54:56 +04:00 committed by Colin Walters
parent 542ad4db03
commit 00f0795a84
2 changed files with 9 additions and 74 deletions

View File

@ -284,20 +284,9 @@ g_icon_new_from_tokens (char **tokens,
int num_tokens;
int i;
icon = NULL;
klass = NULL;
num_tokens = g_strv_length (tokens);
if (num_tokens < 1)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Wrong number of tokens (%d)"),
num_tokens);
goto out;
}
g_return_val_if_fail (num_tokens >= 1, NULL);
typename = tokens[0];
version_str = strchr (typename, '.');
@ -309,64 +298,23 @@ g_icon_new_from_tokens (char **tokens,
type = g_type_from_name (tokens[0]);
if (type == 0)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("No type for class name %s"),
tokens[0]);
goto out;
}
if (!g_type_is_a (type, G_TYPE_ICON))
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Type %s does not implement the GIcon interface"),
tokens[0]);
goto out;
}
g_return_val_if_fail (type != 0, NULL);
g_return_val_if_fail (g_type_is_a (type, G_TYPE_ICON), NULL);
klass = g_type_class_ref (type);
if (klass == NULL)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Type %s is not classed"),
tokens[0]);
goto out;
}
g_return_val_if_fail (klass, NULL);
version = 0;
if (version_str)
{
version = strtol (version_str, &endp, 10);
if (endp == NULL || *endp != '\0')
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Malformed version number: %s"),
version_str);
goto out;
}
g_return_val_if_fail (endp && *endp, NULL);
}
icon_iface = g_type_interface_peek (klass, G_TYPE_ICON);
g_assert (icon_iface != NULL);
if (icon_iface->from_tokens == NULL)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Type %s does not implement from_tokens() on the GIcon interface"),
tokens[0]);
goto out;
}
g_return_val_if_fail (icon_iface->from_tokens, NULL);
for (i = 1; i < num_tokens; i++)
{
@ -379,9 +327,7 @@ g_icon_new_from_tokens (char **tokens,
icon = icon_iface->from_tokens (tokens + 1, num_tokens - 1, version, error);
out:
if (klass != NULL)
g_type_class_unref (klass);
g_type_class_unref (klass);
return icon;
}
@ -465,7 +411,7 @@ g_icon_new_for_string (const gchar *str,
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Can't handle the supplied version of the icon encoding"));
"Can't handle the supplied version of the icon encoding");
return icon;
}

View File

@ -511,17 +511,7 @@ g_themed_icon_from_tokens (gchar **tokens,
gchar **names;
int n;
icon = NULL;
if (version != 0)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Can't handle version %d of GThemedIcon encoding"),
version);
goto out;
}
g_return_val_if_fail (version == 0, NULL);
names = g_new0 (gchar *, num_tokens + 1);
for (n = 0; n < num_tokens; n++)
@ -531,7 +521,6 @@ g_themed_icon_from_tokens (gchar **tokens,
icon = g_themed_icon_new_from_names (names, num_tokens);
g_free (names);
out:
return icon;
}