[gtk/wip/baedert/for-master] label: Only parse mnemonic attributes if we need to



commit 7ad0a21412c16b723ecb5001ab0935860834417e
Author: Timm Bäder <mail baedert org>
Date:   Tue Apr 14 11:11:08 2020 +0200

    label: Only parse mnemonic attributes if we need to

 gtk/gtklabel.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 268d3936dc..05875f59be 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2284,7 +2284,8 @@ no_uline:
       self->mnemonic_keyval = accel_keyval;
 
       /* Extract the text to display */
-      if (!pango_parse_markup (new_text, -1, '_', &attrs, &text, NULL, &error))
+      if (!pango_parse_markup (new_text, -1, '_',
+                               do_mnemonics ? &attrs : NULL, &text, NULL, &error))
         goto error_set;
 
       if (do_mnemonics)
@@ -2312,14 +2313,12 @@ no_uline:
   if (text)
     gtk_label_set_text_internal (self, text);
 
-  if (attrs)
-    {
-      g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
-      self->markup_attrs = attrs;
 
-      if (mnemonic_attr)
-        pango_attr_list_insert_before (self->markup_attrs, mnemonic_attr);
-    }
+  g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
+  self->markup_attrs = attrs;
+
+  if (mnemonic_attr)
+    pango_attr_list_insert_before (self->markup_attrs, mnemonic_attr);
 
   return;
 


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