[gtk/office-runner-crash] Fix a crash in gtk-builder-tool



commit c0b8eb30decf2342b747117039a18dfaeb1b6be8
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 26 15:34:15 2019 +0200

    Fix a crash in gtk-builder-tool
    
    Crash pointed out by Bastien Nocera.
    
    Testcase included.

 gtk/tools/gtk-builder-tool-simplify.c              |   5 +
 .../simplify-data-3to4/office-runner.expected      | 207 +++++++++++++++
 .../tools/simplify-data-3to4/office-runner.ui      | 286 +++++++++++++++++++++
 3 files changed, 498 insertions(+)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index a7f7ecbcbb..dc6462882e 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -793,6 +793,7 @@ rewrite_stack_child (Element *child, MyParserData *data)
   new_object->attribute_values = g_new0 (char *, 2);
   new_object->attribute_values[0] = g_strdup ("GtkStackPage");
   new_object->children = packing->children;
+  new_object->parent = child;
   packing->children = NULL;
 
   prop = g_new0 (Element, 1);
@@ -802,6 +803,7 @@ rewrite_stack_child (Element *child, MyParserData *data)
   prop->attribute_values = g_new0 (char *, 2);
   prop->attribute_values[0] = g_strdup ("child");
   prop->children = g_list_append (prop->children, object);
+  prop->parent = new_object;
   new_object->children = g_list_append (new_object->children, prop);
       
   g_list_free (child->children);
@@ -940,6 +942,7 @@ rewrite_notebook_page (Element *child, Element *tab, MyParserData *data)
   new_object->attribute_names[0] = g_strdup ("class");
   new_object->attribute_values = g_new0 (char *, 2);
   new_object->attribute_values[0] = g_strdup ("GtkNotebookPage");
+  new_object->parent = child;
   if (packing)
     {
       new_object->children = packing->children;
@@ -953,6 +956,7 @@ rewrite_notebook_page (Element *child, Element *tab, MyParserData *data)
   prop->attribute_values = g_new0 (char *, 2);
   prop->attribute_values[0] = g_strdup ("child");
   prop->children = g_list_append (prop->children, object);
+  prop->parent = new_object;
   new_object->children = g_list_append (new_object->children, prop);
 
   if (tab_obj)
@@ -964,6 +968,7 @@ rewrite_notebook_page (Element *child, Element *tab, MyParserData *data)
       prop->attribute_values = g_new0 (char *, 2);
       prop->attribute_values[0] = g_strdup ("tab");
       prop->children = g_list_append (prop->children, tab_obj);
+      prop->parent = new_object;
       new_object->children = g_list_append (new_object->children, prop);
     }
 
diff --git a/testsuite/tools/simplify-data-3to4/office-runner.expected 
b/testsuite/tools/simplify-data-3to4/office-runner.expected
new file mode 100644
index 0000000000..6b32fa1616
--- /dev/null
+++ b/testsuite/tools/simplify-data-3to4/office-runner.expected
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow" id="window1">
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">Office Runner</property>
+    <property name="resizable">0</property>
+    <property name="window_position">center</property>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="margin_left">12</property>
+        <property name="margin_right">12</property>
+        <property name="margin_bottom">12</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkNotebook" id="notebook1">
+            <property name="show_tabs">0</property>
+            <property name="show_border">0</property>
+            <child>
+              <object class="GtkNotebookPage">
+                <property name="child">
+                  <object class="GtkGrid" id="grid1">
+                    <property name="row_spacing">12</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="run_image">
+                        <property name="vexpand">1</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="valign">start</property>
+                        <property name="hexpand">1</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes"> • Click the &quot;Run!&quot; button, and 
then dash to your desk or meeting.
+ • You are allowed to close your laptop lid to run faster
+</property>
+                        <property name="use_markup">1</property>
+                        <layout>
+                          <property name="left_attach">1</property>
+                          <property name="top_attach">1</property>
+                        </layout>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label7">
+                        <property name="label" translatable="yes">Rules</property>
+                        <attributes>
+                          <attribute name="scale" value="2"></attribute>
+                        </attributes>
+                        <layout>
+                          <property name="left_attach">1</property>
+                        </layout>
+                      </object>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </property>
+                <property name="tab">
+                  <object class="GtkLabel" id="label1">
+                    <property name="label" translatable="no">page 1</property>
+                  </object>
+                </property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkNotebookPage">
+                <property name="position">1</property>
+                <property name="child">
+                  <object class="GtkGrid" id="grid2">
+                    <property name="row_spacing">12</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="time_image">
+                        <property name="vexpand">1</property>
+                        <layout>
+                          <property name="left_attach">1</property>
+                        </layout>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="time_label">
+                        <property name="hexpand">1</property>
+                        <property name="vexpand">1</property>
+                        <property name="label" translatable="no">00:00.00</property>
+                        <attributes>
+                          <attribute name="scale" value="10"></attribute>
+                          <attribute name="font-features" value="tnum 1"></attribute>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                </property>
+                <property name="tab">
+                  <object class="GtkLabel" id="label2">
+                    <property name="label" translatable="no">page 2</property>
+                  </object>
+                </property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkNotebookPage">
+                <property name="position">2</property>
+                <property name="child">
+                  <object class="GtkGrid" id="grid3">
+                    <property name="hexpand">1</property>
+                    <property name="row_spacing">12</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="trophy_image"/>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="box2">
+                        <property name="valign">center</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkLabel" id="result_label">
+                            <property name="valign">start</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="no">Silver Trophy!</property>
+                            <property name="use_markup">1</property>
+                            <style>
+                              <class name="dim-label"/>
+                            </style>
+                            <attributes>
+                              <attribute name="weight" value="bold"></attribute>
+                              <attribute name="scale" value="1.5"></attribute>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="current_time_label">
+                            <property name="valign">start</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="no">You managed to finish the route with 
the 2nd best time ever, &lt;b&gt;48.15 seconds!&lt;/b&gt;    </property>
+                            <property name="use_markup">1</property>
+                            <property name="wrap">1</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="better_time_label">
+                            <property name="valign">start</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="no">Only &lt;b&gt;3.75 seconds&lt;/b&gt; 
separate you from the gold trophy!</property>
+                            <property name="use_markup">1</property>
+                            <property name="wrap">1</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                          </packing>
+                        </child>
+                        <layout>
+                          <property name="left_attach">1</property>
+                        </layout>
+                      </object>
+                    </child>
+                  </object>
+                </property>
+                <property name="tab">
+                  <object class="GtkLabel" id="label3">
+                    <property name="label" translatable="no">page 3</property>
+                  </object>
+                </property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="run_button">
+            <property name="can_focus">1</property>
+            <property name="receives_default">1</property>
+            <property name="hexpand">1</property>
+            <property name="vexpand">1</property>
+            <property name="use_action_appearance">False</property>
+            <child>
+              <object class="GtkLabel" id="run_button_label">
+                <property name="label" translatable="yes">Run!</property>
+                <attributes>
+                  <attribute name="scale" value="3"></attribute>
+                </attributes>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data-3to4/office-runner.ui 
b/testsuite/tools/simplify-data-3to4/office-runner.ui
new file mode 100644
index 0000000000..e4a237f78f
--- /dev/null
+++ b/testsuite/tools/simplify-data-3to4/office-runner.ui
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">Office Runner</property>
+    <property name="resizable">False</property>
+    <property name="window_position">center</property>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin_left">12</property>
+        <property name="margin_right">12</property>
+        <property name="margin_bottom">12</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="show_tabs">False</property>
+            <property name="show_border">False</property>
+            <child>
+              <object class="GtkGrid" id="grid1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <object class="GtkImage" id="run_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="vexpand">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="valign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"> • Click the "Run!" button, and then dash to 
your desk or meeting.
+ • You are allowed to close your laptop lid to run faster
+</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Rules</property>
+                    <attributes>
+                      <attribute name="scale" value="2"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="no">page 1</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid" id="grid2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <object class="GtkImage" id="time_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="vexpand">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="time_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="label" translatable="no">00:00.00</property>
+                    <attributes>
+                      <attribute name="scale" value="10"/>
+                      <attribute name="font-features" value="tnum 1"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="no">page 2</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid" id="grid3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <object class="GtkImage" id="trophy_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="box2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="valign">center</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="GtkLabel" id="result_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">start</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="no">Silver Trophy!</property>
+                        <property name="use_markup">True</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                          <attribute name="scale" value="1.5"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="current_time_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">start</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="no">You managed to finish the route with the 
2nd best time ever, &lt;b&gt;48.15 seconds!&lt;/b&gt;        </property>
+                        <property name="use_markup">True</property>
+                        <property name="wrap">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="better_time_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">start</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="no">Only &lt;b&gt;3.75 seconds&lt;/b&gt; 
separate you from the gold trophy!</property>
+                        <property name="use_markup">True</property>
+                        <property name="wrap">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="no">page 3</property>
+              </object>
+              <packing>
+                <property name="position">2</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="run_button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="use_action_appearance">False</property>
+            <child>
+              <object class="GtkLabel" id="run_button_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Run!</property>
+                <attributes>
+                  <attribute name="scale" value="3"/>
+                </attributes>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]