[gtk] builder-tool: Fix a thinko
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] builder-tool: Fix a thinko
- Date: Wed, 26 Feb 2020 15:02:43 +0000 (UTC)
commit fa75d7f480a0cc34942743da0f53d488e287a5fb
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 26 09:59:14 2020 -0500
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 +++++++++++-------
testsuite/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 @@
<property name="active">1</property>
<property name="can_focus">1</property>
<property name="receives_default">1</property>
- <property name="expand">True</property>
+ <property name="vexpand">1</property>
+ <property name="hexpand">1</property>
<property name="margin-top">10</property>
<property name="margin-right">10</property>
<property name="margin-bottom">10</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]