Package: glade Version: 3.20.2-1 Severity: normal Tags: upstream patch Dear Maintainer,
When attempting to add a cell renderer to a GTKTreeViewColumn, it was discovered that this feature is broken in glade. To reproduce: Add a GTKTreeView to a GTKWindow in glade. Right click the GTKTreeView and select "Edit" in the popup window. In the Hierarchy pane, click the + (plus) icon to add a new GTKTreeViewColumn. Right click the new column and choose "Add child Text" from the popup window. It is expected that a GTKCellRendererText object would appear as a child of the GTKTreeViewColumn, but instead, nothing happens. Other buggy behavior can be seen in this same Hierarchy pane such as occasional segfaults when removing columns. After debugging, it seems that this behavior and probable buggy behavior with other GTK+ plugins using the glade-base-editor can be attributed to mangling of GType values that occurs when packing these values into gints. GType is an 8-byte unsigned value while gint is a signed 4 byte value (at least on amd64). These patches were tested on a backport of glade from unstable (3.20.2-1) to stretch with libglib-dev and debhelper build-dep versions relaxed to meet those in stretch, the behavior bug is also present in the stable package (3.20.0-2) and appears to be present upstream (untested but apparent in source and unmentioned in Changelog). The report has not been forwarded upstream. The patch consists of a macro wrapper to pack GTypes in a larger integer type and a test to preempt regression. Ideally, most of this would be provided by glib. -- System Information: Debian Release: 9.3 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.9.0-4-amd64 (SMP w/8 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages glade depends on: ii libc6 2.24-11+deb9u1 ii libcairo2 1.14.8-1 ii libgdk-pixbuf2.0-0 2.36.5-2+deb9u1 ii libgladeui-2-6 3.20.2-1 ii libglib2.0-0 2.50.3-2 ii libgtk-3-0 3.22.11-1 ii libpango-1.0-0 1.40.5-1 Versions of packages glade recommends: ii devhelp 3.22.0-1+b1 ii libgtk-3-dev 3.22.11-1 glade suggests no packages. -- no debconf information *** /home/william/Desktop/glade-bug/Avoid_data_loss_when_packing_gtype.patch Description: Avoid data loss when packing GType Gtypes are unsigned longs but were packed into a signed int causing data loss and undesirable behavior in the tree view editor and likely all other gtk plugins utilizing glade-base-editor. . glade (3.20.0-2) stable; urgency=medium . Author: William Panlener <wpanle...@gmail.com> Bug-Debian: https://bugs.debian.org/837832 --- Bug-Debian: https://bugs.debian.org/<bugnumber> Forwarded: <no> Last-Update: 2017-12-25 --- glade-3.20.0.orig/gladeui/glade-base-editor.c +++ glade-3.20.0/gladeui/glade-base-editor.c @@ -784,7 +784,7 @@ glade_base_editor_add_item_activate (Gtk GladeBaseEditor *e) { GObject *item = G_OBJECT (menuitem); - GType type = GPOINTER_TO_INT (g_object_get_data (item, "object_type")); + GType type = GPOINTER_TO_TYPE (g_object_get_data (item, "object_type")); GladeBaseEditorAddMode add_mode = GPOINTER_TO_INT (g_object_get_data (item, "object_add_mode")); @@ -825,7 +825,7 @@ glade_base_editor_popup (GladeBaseEditor gtk_widget_show (item); g_object_set_data (G_OBJECT (item), "object_type", - GINT_TO_POINTER (iter_type)); + GTYPE_TO_POINTER (iter_type)); g_object_set_data (G_OBJECT (item), "object_add_mode", GINT_TO_POINTER (ADD_SIBLING)); @@ -857,7 +857,7 @@ glade_base_editor_popup (GladeBaseEditor gtk_widget_show (item); g_object_set_data (G_OBJECT (item), "object_type", - GINT_TO_POINTER (iter_type)); + GTYPE_TO_POINTER (iter_type)); g_object_set_data (G_OBJECT (item), "object_add_mode", GINT_TO_POINTER (ADD_CHILD)); --- glade-3.20.0.orig/gladeui/glade-base-editor.h +++ glade-3.20.0/gladeui/glade-base-editor.h @@ -34,6 +34,9 @@ G_BEGIN_DECLS #define GLADE_IS_BASE_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_TYPE_BASE_EDITOR)) #define GLADE_BASE_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_TYPE_BASE_EDITOR, GladeBaseEditorClass)) +#define GTYPE_TO_POINTER(x) GSIZE_TO_POINTER(x) +#define GPOINTER_TO_TYPE(x) GPOINTER_TO_SIZE(x) + typedef struct _GladeBaseEditor GladeBaseEditor; typedef struct _GladeBaseEditorPrivate GladeBaseEditorPrivate; typedef struct _GladeBaseEditorClass GladeBaseEditorClass; --- glade-3.20.0.orig/tests/Makefile.am +++ glade-3.20.0/tests/Makefile.am @@ -3,6 +3,7 @@ include $(top_srcdir)/glade-rules.mk TEST_PROGS = \ create-widgets \ add-child \ + misc \ toplevel-order noinst_PROGRAMS = $(TEST_PROGS) @@ -40,6 +41,13 @@ add_child_LDFLAGS = $(progs_libs) add_child_LDADD = $(progs_ldadd) add_child_SOURCES = add-child.c +# Test miscellaneous conditions +misc_CPPFLAGS = $(progs_cppflags) +misc_CFLAGS = $(progs_cflags) +misc_LDFLAGS = $(progs_libs) +misc_LDADD = $(progs_ldadd) +misc_SOURCES = misc.c + TOPLEVEL_ORDER_FILES = \ toplevel-order-resources.gresource.xml \ toplevel_order_test.glade \ --- /dev/null +++ glade-3.20.0/tests/misc.c @@ -0,0 +1,30 @@ +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> + +#include <gladeui/glade-base-editor.h> + +static void +test_pack_gtype (void) +{ + GType a, b; + + /* Intentional underflow to get largest possible integer */ + a = -1; + a = (a >> 1); + + b = GPOINTER_TO_TYPE(GTYPE_TO_POINTER(a)); + + g_assert (a == b); +} + +int +main (int argc, + char *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_func("/misc/pack_gtype", test_pack_gtype); +