Commit f442733b authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Fix some mistakes.

* remove useless g_obect_{set,get}_property call.
* free GError on error.
parent a6fe5bd8
......@@ -338,9 +338,7 @@ eek_gtk_keyboard_set_property (GObject *object,
eek_gtk_keyboard_set_keyboard (EEK_GTK_KEYBOARD(object), keyboard);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -66,8 +66,13 @@ eek_gtk_renderer_real_get_icon_surface (EekRenderer *self,
size,
0,
&error);
if (pixbuf == NULL)
if (pixbuf == NULL) {
g_warning ("can't get icon pixbuf for %s: %s",
icon_name,
error->message);
g_error_free (error);
return NULL;
}
surface = pixbuf_to_cairo_surface (pixbuf);
g_object_unref (pixbuf);
......
......@@ -254,9 +254,7 @@ eek_key_set_property (GObject *object,
eek_key_set_oref (EEK_KEY(object), g_value_get_uint (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -290,9 +288,7 @@ eek_key_get_property (GObject *object,
g_value_set_uint (value, eek_key_get_oref (EEK_KEY(object)));
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -187,9 +187,7 @@ eek_keyboard_set_property (GObject *object,
g_value_get_enum (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -211,9 +209,7 @@ eek_keyboard_get_property (GObject *object,
eek_keyboard_get_modifier_behavior (EEK_KEYBOARD(object)));
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -733,9 +733,7 @@ eek_renderer_set_property (GObject *object,
g_object_ref (priv->pcontext);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -753,9 +751,7 @@ eek_renderer_get_property (GObject *object,
g_value_set_object (value, priv->keyboard);
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -303,9 +303,7 @@ eek_section_set_property (GObject *object,
g_value_get_int (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -321,9 +319,7 @@ eek_section_get_property (GObject *object,
g_value_set_int (value, eek_section_get_angle (EEK_SECTION(object)));
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -122,9 +122,7 @@ eek_symbol_set_property (GObject *object,
g_value_get_string (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -154,9 +152,7 @@ eek_symbol_get_property (GObject *object,
eek_symbol_get_icon_name (EEK_SYMBOL(object)));
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -100,9 +100,7 @@ eek_text_set_property (GObject *object,
priv->text = g_strdup (g_value_get_string (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -119,9 +117,7 @@ eek_text_get_property (GObject *object,
g_value_set_string (value, priv->text);
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -386,6 +386,7 @@ eek_xkb_layout_set_property (GObject *object,
eek_xkb_layout_set_symbols (EEK_XKB_LAYOUT(object), name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -416,6 +417,7 @@ eek_xkb_layout_get_property (GObject *object,
g_value_set_string (value, name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -101,27 +101,27 @@ eek_xkl_layout_set_property (GObject *object,
{
EekXklLayout *layout = EEK_XKL_LAYOUT(object);
switch (prop_id)
{
case PROP_MODEL:
eek_xkl_layout_set_model (EEK_XKL_LAYOUT(object),
g_value_get_string (value));
break;
case PROP_LAYOUTS:
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
case PROP_VARIANTS:
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
case PROP_OPTIONS:
eek_xkl_layout_set_options (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
default:
break;
}
switch (prop_id) {
case PROP_MODEL:
eek_xkl_layout_set_model (EEK_XKL_LAYOUT(object),
g_value_get_string (value));
break;
case PROP_LAYOUTS:
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
case PROP_VARIANTS:
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
case PROP_OPTIONS:
eek_xkl_layout_set_options (EEK_XKL_LAYOUT(object),
g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
......@@ -132,31 +132,27 @@ eek_xkl_layout_get_property (GObject *object,
{
EekXklLayout *layout = EEK_XKL_LAYOUT(object);
switch (prop_id)
{
case PROP_MODEL:
g_value_set_string
(value,
eek_xkl_layout_get_model (EEK_XKL_LAYOUT(object)));
break;
case PROP_LAYOUTS:
g_value_set_boxed
(value,
eek_xkl_layout_get_layouts (EEK_XKL_LAYOUT(object)));
break;
case PROP_VARIANTS:
g_value_set_boxed
(value,
eek_xkl_layout_get_variants (EEK_XKL_LAYOUT(object)));
break;
case PROP_OPTIONS:
g_value_set_boxed
(value,
eek_xkl_layout_get_options (EEK_XKL_LAYOUT(object)));
break;
default:
break;
}
switch (prop_id) {
case PROP_MODEL:
g_value_set_string (value,
eek_xkl_layout_get_model (EEK_XKL_LAYOUT(object)));
break;
case PROP_LAYOUTS:
g_value_set_boxed (value,
eek_xkl_layout_get_layouts (EEK_XKL_LAYOUT(object)));
break;
case PROP_VARIANTS:
g_value_set_boxed (value,
eek_xkl_layout_get_variants (EEK_XKL_LAYOUT(object)));
break;
case PROP_OPTIONS:
g_value_set_boxed (value,
eek_xkl_layout_get_options (EEK_XKL_LAYOUT(object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
......
......@@ -552,20 +552,30 @@ eek_xml_layout_real_create_keyboard (EekLayout *self,
nread = g_input_stream_read (G_INPUT_STREAM(priv->source),
buffer, sizeof buffer, NULL,
&error);
if (nread < 0) {
g_warning ("error reading XML layout: %s",
error->message);
g_clear_error (&error);
}
if (nread <= 0)
break;
error = NULL;
if (!g_markup_parse_context_parse (pcontext, buffer, nread, &error))
if (!g_markup_parse_context_parse (pcontext, buffer, nread,
&error)) {
g_warning ("can't parse XML layout: %s", error->message);
g_clear_error (&error);
break;
}
}
if (error)
g_warning ("%s", error->message);
error = NULL;
g_markup_parse_context_end_parse (pcontext, &error);
if (error)
g_warning ("%s", error->message);
if (!g_markup_parse_context_end_parse (pcontext, &error)) {
g_warning ("can't finish parsing XML layout: %s",
error->message);
g_error_free (error);
}
g_markup_parse_context_free (pcontext);
......@@ -630,9 +640,7 @@ eek_xml_layout_set_property (GObject *object,
g_value_get_object (value));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -649,9 +657,7 @@ eek_xml_layout_get_property (GObject *object,
eek_xml_layout_get_source (EEK_XML_LAYOUT(object)));
break;
default:
g_object_get_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......
......@@ -180,6 +180,9 @@ eekboard_client_new (GDBusConnection *connection,
return client;
}
g_warning ("can't create client: %s", error->message);
g_error_free (error);
return NULL;
}
......@@ -227,8 +230,11 @@ eekboard_client_create_context (EekboardClient *client,
-1,
cancellable,
&error);
if (!variant)
if (!variant) {
g_warning ("failed to call CreateContext: %s", error->message);
g_error_free (error);
return NULL;
}
g_variant_get (variant, "(&s)", &object_path);
connection = g_dbus_proxy_get_connection (G_DBUS_PROXY(client));
......@@ -260,6 +266,10 @@ eekboard_async_ready_callback (GObject *source_object,
&error);
if (result)
g_variant_unref (result);
else {
g_warning ("error in D-Bus proxy call: %s", error->message);
g_error_free (error);
}
}
/**
......
......@@ -195,8 +195,12 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
error = NULL;
input = g_file_read (file, NULL, &error);
g_object_unref (file);
if (input == NULL)
if (input == NULL) {
g_warning ("can't read keyboard file %s: %s",
keyboard_type, error->message);
g_error_free (error);
return NULL;
}
layout = eek_xml_layout_new (G_INPUT_STREAM(input));
}
keyboard = eek_keyboard_new (layout, CSW, CSH);
......@@ -249,9 +253,7 @@ eekboard_context_service_set_property (GObject *object,
priv->fullscreen = g_value_get_boolean (value);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -285,9 +287,7 @@ eekboard_context_service_get_property (GObject *object,
g_value_set_boolean (value, priv->fullscreen);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
......@@ -351,6 +351,12 @@ eekboard_context_service_constructed (GObject *object)
context,
NULL,
&error);
if (priv->registration_id == 0) {
g_warning ("failed to register context object: %s",
error->message);
g_error_free (error);
}
}
}
......@@ -501,7 +507,11 @@ eekboard_context_service_init (EekboardContextService *context)
error = NULL;
priv->introspection_data =
g_dbus_node_info_new_for_xml (introspection_xml, &error);
g_assert (priv->introspection_data != NULL);
if (priv->introspection_data == NULL) {
g_warning ("failed to parse D-Bus XML: %s", error->message);
g_error_free (error);
g_assert_not_reached ();
}
priv->keyboard_hash =
g_hash_table_new_full (g_direct_hash,
......@@ -535,14 +545,21 @@ emit_visibility_changed_signal (EekboardContextService *context,
if (priv->connection && priv->enabled) {
GError *error = NULL;
g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"VisibilityChanged",
g_variant_new ("(b)", visible),
&error);
g_assert_no_error (error);
gboolean retval;
retval = g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"VisibilityChanged",
g_variant_new ("(b)", visible),
&error);
if (!retval) {
g_warning ("failed to emit VisibilityChanged signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
}
}
......@@ -554,14 +571,21 @@ emit_group_changed_signal (EekboardContextService *context,
if (priv->connection && priv->enabled) {
GError *error = NULL;
g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"GroupChanged",
g_variant_new ("(i)", group),
&error);
g_assert_no_error (error);
gboolean retval;
retval = g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"GroupChanged",
g_variant_new ("(i)", group),
&error);
if (!retval) {
g_warning ("failed to emit GroupChanged signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
}
}
......@@ -577,22 +601,28 @@ emit_key_activated_dbus_signal (EekboardContextService *context,
guint modifiers = eek_keyboard_get_modifiers (priv->keyboard);
GVariant *variant;
GError *error;
gboolean retval;
variant = eek_serializable_serialize (EEK_SERIALIZABLE(symbol));
error = NULL;
g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"KeyActivated",
g_variant_new ("(svu)",
keyname,
variant,
modifiers),
&error);
retval = g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"KeyActivated",
g_variant_new ("(svu)",
keyname,
variant,
modifiers),
&error);
g_variant_unref (variant);
g_assert_no_error (error);
if (!retval) {
g_warning ("failed to emit KeyActivated signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
}
}
......@@ -919,17 +949,24 @@ eekboard_context_service_enable (EekboardContextService *context)
g_return_if_fail (priv->connection);
if (!priv->enabled) {
gboolean retval;
priv->enabled = TRUE;
error = NULL;
g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"Enabled",
NULL,
&error);
g_assert_no_error (error);
retval = g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"Enabled",
NULL,
&error);
if (!retval) {
g_warning ("failed to emit Enabled signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
g_signal_emit_by_name (context, "enabled", NULL);
}
}
......@@ -951,17 +988,24 @@ eekboard_context_service_disable (EekboardContextService *context)
g_return_if_fail (priv->connection);
if (priv->enabled) {
gboolean retval;
priv->enabled = FALSE;
error = NULL;
g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"Disabled",
NULL,
&error);
g_assert_no_error (error);
retval = g_dbus_connection_emit_signal (priv->connection,
NULL,
priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"Disabled",
NULL,
&error);
if (!retval) {
g_warning ("failed to emit Disabled signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
g_signal_emit_by_name (context, "disabled", NULL);
}
}
......
......@@ -350,6 +350,10 @@ eekboard_context_new (GDBusConnection *connection,
return context;
}
g_warning ("can't create context client: %s", error->message);
g_error_free (error);
return NULL;
}
......@@ -366,6 +370,10 @@ context_async_ready_callback (GObject *source_object,
&error);
if (result)
g_variant_unref (result);
else {
g_warning ("error in D-Bus proxy call: %s", error->message);
g_error_free (error);
}
}
/**
......@@ -403,6 +411,10 @@ eekboard_context_add_keyboard (EekboardContext *context,
return keyboard_id;