From fa75d7f480a0cc34942743da0f53d488e287a5fb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 26 Feb 2020 09:59:14 -0500 Subject: [PATCH] builder-tool: Fix a thinko We can't rely on the pspec for a removed property. This code worked until I actually removed the properties. Update the tests to reflect this. --- gtk/tools/gtk-builder-tool-simplify.c | 18 +++++++++++------- .../tools/simplify-data-3to4/grid.expected | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index c6b2d56075..a2b42d135b 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -733,7 +733,8 @@ maybe_rename_property (Element *element, MyParserData *data) int i, k, l; PropKind kind; int prop_name_index = 0; - GParamSpec *pspec; + GType type; + char *canonical_name; kind = get_prop_kind (element); @@ -751,15 +752,16 @@ maybe_rename_property (Element *element, MyParserData *data) if (property_name == NULL) return; + + type = g_type_from_name (class_name); - pspec = get_property_pspec (data, class_name, property_name, kind); - if (pspec == NULL) - return; - + canonical_name = g_strdup (property_name); + g_strdelimit (canonical_name, "_", '-'); + for (k = 0; k < G_N_ELEMENTS (props); k++) { - if (pspec->owner_type == props[k].type && - strcmp (pspec->name, props[k].property) == 0 && + if (g_type_is_a (type, props[k].type) && + strcmp (canonical_name, props[k].property) == 0 && kind == props[k].kind) { g_free (element->attribute_values[prop_name_index]); @@ -787,6 +789,8 @@ maybe_rename_property (Element *element, MyParserData *data) break; } } + + g_free (canonical_name); } static Element * diff --git a/testsuite/tools/simplify-data-3to4/grid.expected b/testsuite/tools/simplify-data-3to4/grid.expected index 955cf2c541..12db5c21e2 100644 --- a/testsuite/tools/simplify-data-3to4/grid.expected +++ b/testsuite/tools/simplify-data-3to4/grid.expected @@ -9,7 +9,8 @@ 1 1 1 - True + 1 + 1 10 10 10