GNOME Bugzilla – Bug 738274
Inconsistent handling of mnemonic keyval for GTK Labels with markup content causes some mnemonics to be ignored
Last modified: 2015-02-12 02:54:11 UTC
Observed in 2.24.23 (From Ubuntu 14.04's package repositories). Labels with markup content sometimes behave erratically when handling mnemonics. This behavior seems to arise from inconsistencies between gtk_label_set_uline_text_internal and gtk_label_set_markup_internal. One or the other function will be called by gtk_label_recalculate, depending on whether markup mode is enabled for the label. In gtk_label_set_uline_text_internal, mnemonic_keyval is always set from the output of separate_uline_pattern. However, in gtk_label_set_markup_internal, the call to separate_uline_pattern only occurs if the mnemonic hint is not visible, and the accel character it discovers is discarded and the mnemonic-less string saved. mnemonic_keyval is then set based on the output of pango_parse_markup, which will not find an accelerator character if seperate_uline_pattern already removed it, and mnemonic_keyval is then set to the void symbol. This behavior is in contrast to gtk_label_set_uline_text_internal, which always saves the correct mnemonic_keyval, even if the mnemonic hint is not visible. The real effect of this behavior is that if any GTK events that affect a label in markup mode are processed between the key presses used to activate a mnemonic, the logic in gtk_label_set_markup_internal may reset the label's mnemonic_keyval and cause the mnemonic combination to fail to trigger the mnemonic action (since, at the moment it was received, there was no mnemonic key associated with the control). This condition has been observed in several applications when spurious focus events were processed between the events comprising the keystrokes of the mnemonics. The source of these spurious focus events is unclear, and I have not been able to isolate it, however their occurrence does not impede the mnemonics of labels that are not in markup mode. Inspection of GTK 3.10.8 (the one in Ubuntu 14.04's repositories) indicates that the problem probably still exists: the mnemonic will be stripped from markup mode labels during gtk_label_set_markup_internal, and the label's mnemonic_keyval cleared, if the mnemonic hint for the label is not to be shown. I have not checked any versions other than 3.10.8 and 2.24.23.
the most useful piece of information here would be a few concrete examples
I had some time to look at this again and it looks like I was mistaken in my analysis of the versions impacted. The problem was patched somewhere between 3.6 and 3.8, newer versions are not affected anymore. I'm not sure there's any motivation to fix this in 2.24 since it's several years old at this point. I'm glad it's been fixed because a concrete example was proving hard to create, it was racy and reproduced differently even using the same compiled software on different machines. *** This bug has been marked as a duplicate of bug 674759 ***