summaryrefslogtreecommitdiff
path: root/bus/ibusimpl.c
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2023-02-18 19:52:14 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2023-02-18 19:52:14 +0900
commitecfae1678b117c95264e062deddf9562f902c03d (patch)
tree9066a26fee698327e824db902eae3708d14a90dc /bus/ibusimpl.c
parent2a235c8c33f1de56df4873fe3662d5beb1355715 (diff)
downloadibus-ecfae1678b117c95264e062deddf9562f902c03d.tar.gz
Return error if D-Bus set/get property method is failed
D-Bus set/get property methods are called from GDBusConnection APIs invoke_set_property_in_idle_cb() and invoke_get_property_in_idle_cb() and the error values cannot be null if the methods are failed. BUG=rhbz#2169205
Diffstat (limited to 'bus/ibusimpl.c')
-rw-r--r--bus/ibusimpl.c86
1 files changed, 37 insertions, 49 deletions
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
index c2ae88df..f2ab2b30 100644
--- a/bus/ibusimpl.c
+++ b/bus/ibusimpl.c
@@ -700,11 +700,14 @@ _ibus_get_address (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
- if (error) {
- *error = NULL;
+ GVariant *retval = g_variant_new_string (bus_server_get_address ());
+ if (!retval) {
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Cannot get IBus address");
}
-
- return g_variant_new_string (bus_server_get_address ());
+ return retval;
}
static void
@@ -1213,9 +1216,6 @@ _ibus_get_current_input_context (BusIBusImpl *ibus,
GError **error)
{
GVariant *retval = NULL;
- if (error) {
- *error = NULL;
- }
if (!ibus->focused_context)
{
@@ -1359,14 +1359,11 @@ _ibus_get_engines (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
+ GVariant *retval;
GVariantBuilder builder;
GList *engines = NULL;
GList *p;
- if (error) {
- *error = NULL;
- }
-
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
engines = g_hash_table_get_values (ibus->engine_table);
@@ -1379,7 +1376,9 @@ _ibus_get_engines (BusIBusImpl *ibus,
g_list_free (engines);
- return g_variant_builder_end (&builder);
+ retval = g_variant_builder_end (&builder);
+ g_assert (retval);
+ return retval;
}
static void
@@ -1444,13 +1443,10 @@ _ibus_get_active_engines (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
+ GVariant *retval;
GVariantBuilder builder;
GList *p;
- if (error) {
- *error = NULL;
- }
-
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
for (p = ibus->register_engine_list; p != NULL; p = p->next) {
@@ -1459,7 +1455,9 @@ _ibus_get_active_engines (BusIBusImpl *ibus,
ibus_serializable_serialize ((IBusSerializable *) p->data));
}
- return g_variant_builder_end (&builder);
+ retval = g_variant_builder_end (&builder);
+ g_assert (retval);
+ return retval;
}
static void
@@ -1528,10 +1526,8 @@ _ibus_get_use_sys_layout (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
- if (error) {
+ if (error)
*error = NULL;
- }
-
return g_variant_new_boolean (ibus->use_sys_layout);
}
@@ -1566,10 +1562,8 @@ _ibus_get_use_global_engine (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
- if (error) {
+ if (error)
*error = NULL;
- }
-
return g_variant_new_boolean (ibus->use_global_engine);
}
@@ -1607,10 +1601,6 @@ _ibus_get_global_engine (BusIBusImpl *ibus,
IBusEngineDesc *desc = NULL;
GVariant *retval = NULL;
- if (error) {
- *error = NULL;
- }
-
do {
if (!ibus->use_global_engine)
break;
@@ -1790,10 +1780,8 @@ _ibus_get_global_engine_enabled (BusIBusImpl *ibus,
{
gboolean enabled = FALSE;
- if (error) {
+ if (error)
*error = NULL;
- }
-
do {
if (!ibus->use_global_engine)
break;
@@ -1849,10 +1837,6 @@ _ibus_set_preload_engines (BusIBusImpl *ibus,
BusFactoryProxy *factory = NULL;
GPtrArray *array = g_ptr_array_new ();
- if (error) {
- *error = NULL;
- }
-
g_variant_get (value, "^a&s", &names);
for (i = 0; names[i] != NULL; i++) {
@@ -1912,11 +1896,9 @@ _ibus_get_embed_preedit_text (BusIBusImpl *ibus,
GDBusConnection *connection,
GError **error)
{
- if (error) {
- *error = NULL;
- }
-
- return g_variant_new_boolean (ibus->embed_preedit_text);
+ GVariant *retval = g_variant_new_boolean (ibus->embed_preedit_text);
+ g_assert (retval);
+ return retval;
}
/**
@@ -1931,10 +1913,6 @@ _ibus_set_embed_preedit_text (BusIBusImpl *ibus,
GVariant *value,
GError **error)
{
- if (error) {
- *error = NULL;
- }
-
gboolean embed_preedit_text = g_variant_get_boolean (value);
if (embed_preedit_text != ibus->embed_preedit_text) {
ibus->embed_preedit_text = embed_preedit_text;
@@ -2038,6 +2016,8 @@ bus_ibus_impl_service_get_property (IBusService *service,
{ "EmbedPreeditText", _ibus_get_embed_preedit_text },
};
+ if (error)
+ *error = NULL;
if (g_strcmp0 (interface_name, IBUS_INTERFACE_IBUS) != 0) {
return IBUS_SERVICE_CLASS (
bus_ibus_impl_parent_class)->service_get_property (
@@ -2054,9 +2034,12 @@ bus_ibus_impl_service_get_property (IBusService *service,
}
}
- g_warning ("service_get_property received an unknown property: %s",
- property_name ? property_name : "(null)");
- return NULL;
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "service_get_property received an unknown property: %s",
+ property_name ? property_name : "(null)");
+ g_return_val_if_reached (NULL);
}
/**
@@ -2087,6 +2070,8 @@ bus_ibus_impl_service_set_property (IBusService *service,
{ "EmbedPreeditText", _ibus_set_embed_preedit_text },
};
+ if (error)
+ *error = NULL;
if (g_strcmp0 (interface_name, IBUS_INTERFACE_IBUS) != 0) {
return IBUS_SERVICE_CLASS (
bus_ibus_impl_parent_class)->service_set_property (
@@ -2104,9 +2089,12 @@ bus_ibus_impl_service_set_property (IBusService *service,
}
}
- g_warning ("service_set_property received an unknown property: %s",
- property_name ? property_name : "(null)");
- return FALSE;
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "service_set_property received an unknown property: %s",
+ property_name ? property_name : "(null)");
+ g_return_val_if_reached (FALSE);
}
BusIBusImpl *