After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 533567 - gtk-builder-convert crashes: UnbouldLocalError from GtkImageMenuItem
gtk-builder-convert crashes: UnbouldLocalError from GtkImageMenuItem
Status: RESOLVED DUPLICATE of bug 523932
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
2.12.x
Other All
: Normal critical
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2008-05-17 14:07 UTC by Micah Carrick
Modified: 2008-05-17 14:20 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
Screenshot of Glade Menu Editor which causes crash (39.50 KB, image/jpeg)
2008-05-17 14:08 UTC, Micah Carrick
Details
Screenshot of Glade Menu Editor as work-around (47.70 KB, image/jpeg)
2008-05-17 14:08 UTC, Micah Carrick
Details

Description Micah Carrick 2008-05-17 14:07:04 UTC
Steps to reproduce:
1. Create a New Project in Glade 3.x
2. Drop the default GtkMenuBar into a GtkWindow.
3. Run through gtk-builder-convert


Stack trace:
The default GtkImageMenuItem's in glade are "stock" menus which output a "use_stock" property such as following:


  <widget class="GtkImageMenuItem" id="new_menu_item">
    <property name="visible">True</property>
    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    <property name="label" translatable="yes">_New</property>
    <property name="use_underline">True</property>
    <property name="use_stock">True</property>
    <signal name="activate" handler="on_new_menu_item_activate"/>
  </widget>


When you try to run this through gtk-builder-convert you get the following error:


Traceback (most recent call last):
  • File "/usr/bin/gtk-builder-convert", line 745 in <module>
    sys.exit(main(sys.argv))
  • File "/usr/bin/gtk-builder-convert", line 733 in main
    conv.parse_file(input_filename)
  • File "/usr/bin/gtk-builder-convert", line 161 in parse_file
    self._parse()
  • File "/usr/bin/gtk-builder-convert", line 259 in _parse
    self._convert(node.getAttribute("class"), node)
  • File "/usr/bin/gtk-builder-convert", line 284 in _convert
    self._convert_menu(node)
  • File "/usr/bin/gtk-builder-convert", line 342 in _convert_menu
    item = self._convert_menuitem(uimgr, obj_node)
  • File "/usr/bin/gtk-builder-convert", line 378 in _convert_menuitem
    item = self._convert_menuitem(uimgr, obj_node)
  • File "/usr/bin/gtk-builder-convert", line 374 in _convert_menuitem
    self._add_action_from_menuitem(uimgr, obj_node)
  • File "/usr/bin/gtk-builder-convert", line 425 in _add_action_from_menuitem
    properties['stock_id'] = child
UnboundLocalError: local variable 'child' referenced before assignment


This can be worked around by changing all default GtkImageMenuItem's in glade to "Stock" = 'None' and instead set the "Label" manually and apply a stock image under 'Internal Image Properties'. That results in the following:

  <widget class="GtkImageMenuItem" id="new_menu_item">
    <property name="visible">True</property>
    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    <property name="label" translatable="yes">_New</property>
    <property name="use_underline">True</property>
    <signal name="activate" handler="on_new_menu_item_activate"/>
    <child internal-child="image">
      <widget class="GtkImage" id="menu-item-image1">
        <property name="stock">gtk-new</property>
      </widget>
    </child>
  </widget>


Other information:
Confirmed on Ubuntu "Gutsy" and "Hardy", GTK+ 2.12.9, Glade 3.x
Comment 1 Micah Carrick 2008-05-17 14:08:26 UTC
Created attachment 111045 [details]
Screenshot of Glade Menu Editor which causes crash
Comment 2 Micah Carrick 2008-05-17 14:08:51 UTC
Created attachment 111046 [details]
Screenshot of Glade Menu Editor as work-around
Comment 3 Johan (not receiving bugmail) Dahlin 2008-05-17 14:17:30 UTC

*** This bug has been marked as a duplicate of 523932 ***
Comment 4 Micah Carrick 2008-05-17 14:20:20 UTC
Oops, sorry. I don't know why I didn't see that duplicate.