[gimp] app: don't g_return_if_fail() in gimp_device_info_set_device()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: don't g_return_if_fail() in gimp_device_info_set_device()
- Date: Sun, 17 Jun 2018 13:16:33 +0000 (UTC)
commit f06d0485e697b6a018e4ee774f37a5e7f33aa592
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 17 15:09:56 2018 +0200
app: don't g_return_if_fail() in gimp_device_info_set_device()
when the GimpDeviceInfo already has a device. This is not a programming
error that should trigger a bug report popup, it's something else about
non-uniqueness of device names, or whatever. Simply g_printerr() a more
useful message that can help to debug this and bail out.
app/widgets/gimpdeviceinfo.c | 35 ++++++++++++++++++++++++++---------
app/widgets/gimpdeviceinfo.h | 2 +-
2 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c
index 3847640fff..99dec841cf 100644
--- a/app/widgets/gimpdeviceinfo.c
+++ b/app/widgets/gimpdeviceinfo.c
@@ -600,21 +600,36 @@ gimp_device_info_get_device (GimpDeviceInfo *info,
return info->device;
}
-void
+gboolean
gimp_device_info_set_device (GimpDeviceInfo *info,
GdkDevice *device,
GdkDisplay *display)
{
gint i;
- g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
- g_return_if_fail ((device == NULL && display == NULL) ||
- (GDK_IS_DEVICE (device) && GDK_IS_DISPLAY (display)));
- g_return_if_fail ((info->device == NULL && GDK_IS_DEVICE (device)) ||
- (GDK_IS_DEVICE (info->device) && device == NULL));
- g_return_if_fail (device == NULL ||
- strcmp (gdk_device_get_name (device),
- gimp_object_get_name (info)) == 0);
+ g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), FALSE);
+ g_return_val_if_fail ((device == NULL && display == NULL) ||
+ (GDK_IS_DEVICE (device) && GDK_IS_DISPLAY (display)),
+ FALSE);
+
+ if (device && info->device)
+ {
+ g_printerr ("%s: trying to set GdkDevice '%s' on GimpDeviceInfo "
+ "which already has a device\n",
+ G_STRFUNC, gdk_device_get_name (device));
+ return FALSE;
+ }
+ else if (! device && ! info->device)
+ {
+ g_printerr ("%s: trying to unset GdkDevice of GimpDeviceInfo '%s'"
+ "which has no device\n",
+ G_STRFUNC, gimp_object_get_name (info));
+ return FALSE;
+ }
+
+ g_return_val_if_fail (device == NULL ||
+ strcmp (gdk_device_get_name (device),
+ gimp_object_get_name (info)) == 0, FALSE);
g_object_freeze_notify (G_OBJECT (info));
@@ -695,6 +710,8 @@ gimp_device_info_set_device (GimpDeviceInfo *info,
g_object_notify (G_OBJECT (info), "tool-hardware-id");
g_object_thaw_notify (G_OBJECT (info));
+
+ return TRUE;
}
void
diff --git a/app/widgets/gimpdeviceinfo.h b/app/widgets/gimpdeviceinfo.h
index 9ba6f7fee8..bc3e657118 100644
--- a/app/widgets/gimpdeviceinfo.h
+++ b/app/widgets/gimpdeviceinfo.h
@@ -78,7 +78,7 @@ GimpDeviceInfo * gimp_device_info_new (Gimp *gimp,
GdkDevice * gimp_device_info_get_device (GimpDeviceInfo *info,
GdkDisplay **display);
-void gimp_device_info_set_device (GimpDeviceInfo *info,
+gboolean gimp_device_info_set_device (GimpDeviceInfo *info,
GdkDevice *device,
GdkDisplay *display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]