[vlc-commits] qt: fix double translation of subcats in advanced prefs

Lyndon Brown git at videolan.org
Fri Sep 25 09:26:05 CEST 2020


vlc | branch: master | Lyndon Brown <jnqnfe at gmail.com> | Sat May 25 19:12:23 2019 +0100| [63dc2d5e741d21393bdfae637079ba268cc6ca29] | committer: Pierre Lamot

qt: fix double translation of subcats in advanced prefs

the config_CategoryNameGet() and config_CategoryHelpGet() functions already
perform translation, so the use of qtr() instead of qfu() on the result of
calling those functions is an undesirable double translation.

this issue, combined with two others, results in a null dereference crash
(simply opening the advanced preferences view in the Qt GUI) under
conditions that arose in some work i was doing. those other issues
specifically are:
 1) the lookup table used by those functions is incomplete, missing
    records for a few subcats, thus a null is returned when looking them
    up. (this is addressed in a follow up commit).
 2) the vlc gettext wrappers crash when given a null pointer. (the subject
    of a separate patch discussion).

the explicit null check for help text has been removed here, since every
subcat should have help text along with a name in the lookup tables.

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=63dc2d5e741d21393bdfae637079ba268cc6ca29
---

 .../dialogs/preferences/complete_preferences.cpp   | 25 ++++++----------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/modules/gui/qt/dialogs/preferences/complete_preferences.cpp b/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
index eb8a3e0bff..e6b7c6677d 100644
--- a/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
+++ b/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
@@ -88,7 +88,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
     /* Go through the list of conf */
     for( size_t i = 0; i < confsize; i++ )
     {
-        const char *psz_help;
         QIcon icon;
 
         /* Work on a new item */
@@ -102,12 +101,8 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
 
             /* PrefsItemData Init */
             data = new PrefsItemData( this );
-            data->name = qtr( config_CategoryNameGet( p_item->value.i ) );
-            psz_help = config_CategoryHelpGet( p_item->value.i );
-            if( psz_help )
-                data->help = qtr( psz_help );
-            else
-                data->help.clear();
+            data->name = qfu( config_CategoryNameGet( p_item->value.i ) );
+            data->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
             data->i_type = PrefsItemData::TYPE_CATEGORY;
             data->i_object_id = p_item->value.i;
 
@@ -153,12 +148,8 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
                 /* Data still contains the correct thing */
                 data->i_type = PrefsItemData::TYPE_CATSUBCAT;
                 data->i_subcat_id = p_item->value.i;
-                data->name = qtr( config_CategoryNameGet( p_item->value.i ) );
-                psz_help = config_CategoryHelpGet( p_item->value.i );
-                if( psz_help )
-                    data->help = qtr( psz_help );
-                else
-                    data->help.clear();
+                data->name = qfu( config_CategoryNameGet( p_item->value.i ) );
+                data->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
                 current_item->setData( 0, Qt::UserRole,
                                        QVariant::fromValue( data ) );
                 continue;
@@ -168,12 +159,8 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
 
             /* Process the Data */
             data_sub = new PrefsItemData( this );
-            data_sub->name = qtr( config_CategoryNameGet( p_item->value.i) );
-            psz_help = config_CategoryHelpGet( p_item->value.i );
-            if( psz_help )
-                data_sub->help = qtr( psz_help );
-            else
-                data_sub->help.clear();
+            data_sub->name = qfu( config_CategoryNameGet( p_item->value.i) );
+            data_sub->help = qfu( config_CategoryHelpGet( p_item->value.i ) );
             data_sub->i_type = PrefsItemData::TYPE_SUBCATEGORY;
             data_sub->i_object_id = p_item->value.i;
 



More information about the vlc-commits mailing list