[gimp] app: fix a CRITICAL when physical device axis list changes.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix a CRITICAL when physical device axis list changes.
- Date: Sat, 26 Mar 2022 18:08:07 +0000 (UTC)
commit c799d5235e10df69bfa0cc94b3cf8b25fd740e30
Author: Jehan <jehan girinstud io>
Date: Sat Mar 26 16:27:54 2022 +0100
app: fix a CRITICAL when physical device axis list changes.
After some investigation, I am a bit unsure of why this happens exactly,
but I have a case that the device's axis number listed is not right and
this only becomes apparent after the stylus gets close then further from
the tablet-display. This fixes it, though I think we should look more
closely and reorganize a bit this whole part of our code, which seems
unecessarily complicated and duplicating some data already in GTK/GDK,
like the list of axis, etc. (though maybe it was necessary back when
this was first implemented before more logics got moved to GDK?)
app/widgets/gimpdeviceinfo.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
---
diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c
index 449e04fa7a..15f6188a3e 100644
--- a/app/widgets/gimpdeviceinfo.c
+++ b/app/widgets/gimpdeviceinfo.c
@@ -595,6 +595,39 @@ gimp_device_info_tool_changed (GdkDevice *device,
{
g_object_freeze_notify (G_OBJECT (info));
+ /* GDK docs says that the number of axes can change on "changed"
+ * signal for virtual devices only, but here, I encounter a change of
+ * number of axes on a physical device, the first time when a stylus
+ * approached then moved away from the active surface. When the tool
+ * became then a GDK_DEVICE_TOOL_TYPE_UNKNOWN, I had one more axis
+ * (which created criticals later).
+ * So let's check specifically for such case.
+ */
+ if (info->priv->n_axes != gdk_device_get_n_axes (device))
+ {
+ gint n_axes = gdk_device_get_n_axes (device);
+ gint old_n_axes = info->priv->n_axes;
+ gint i;
+
+ for (i = n_axes; i < info->priv->n_axes; i++)
+ g_free (info->priv->axes_names[i]);
+
+ info->priv->axes_names = g_renew (gchar *, info->priv->axes_names, n_axes + 1);
+ for (i = info->priv->n_axes; i < n_axes + 1; i++)
+ info->priv->axes_names[i] = NULL;
+
+ info->priv->axes_uses = g_renew (GdkAxisUse, info->priv->axes_uses, n_axes);
+ info->priv->n_axes = n_axes;
+
+ for (i = old_n_axes; i < n_axes; i++)
+ {
+ GdkAxisUse axis_use;
+
+ axis_use = gdk_device_get_axis_use (info->priv->device, i);
+ gimp_device_info_set_axis_use (info, i, axis_use);
+ }
+ }
+
g_object_notify (G_OBJECT (info), "tool-type");
g_object_notify (G_OBJECT (info), "tool-serial");
g_object_notify (G_OBJECT (info), "tool-hardware-id");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]