[gnome-settings-daemon] common: Better error handling in device_set_property()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] common: Better error handling in device_set_property()
- Date: Wed, 23 Nov 2011 20:00:14 +0000 (UTC)
commit d411679d055fd7aa2d833f3c6eaa43982077a708
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 23 19:38:46 2011 +0000
common: Better error handling in device_set_property()
plugins/common/gsd-input-helper.c | 39 ++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 2aa2b32..47e9931 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -40,7 +40,7 @@ device_set_property (XDevice *xdevice,
const char *device_name,
PropertyHelper *property)
{
- int rc;
+ int rc, i;
Atom prop;
Atom realtype;
int realformat;
@@ -59,25 +59,30 @@ device_set_property (XDevice *xdevice,
XA_INTEGER, &realtype, &realformat, &nitems,
&bytes_after, &data);
- if (rc == Success && realtype == XA_INTEGER &&
- realformat == property->format && nitems >= property->nitems) {
- int i;
- for (i = 0; i < nitems; i++) {
- switch (property->format) {
- case 8:
- data[i] = property->data.c[i];
- break;
- case 32:
- ((long*)data)[i] = property->data.i[i];
- break;
- }
- }
+ if (rc != Success ||
+ realtype != XA_INTEGER ||
+ realformat != property->format ||
+ nitems < property->nitems) {
+ gdk_error_trap_pop_ignored ();
+ g_warning ("Error reading property \"%s\" for \"%s\"", property->name, device_name);
+ return FALSE;
+ }
- XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- xdevice, prop, XA_INTEGER, realformat,
- PropModeReplace, data, nitems);
+ for (i = 0; i < nitems; i++) {
+ switch (property->format) {
+ case 8:
+ data[i] = property->data.c[i];
+ break;
+ case 32:
+ ((long*)data)[i] = property->data.i[i];
+ break;
+ }
}
+ XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ xdevice, prop, XA_INTEGER, realformat,
+ PropModeReplace, data, nitems);
+
if (gdk_error_trap_pop ()) {
g_warning ("Error in setting \"%s\" for \"%s\"", property->name, device_name);
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]