[vlc-devel] [PATCH 1/2] qt: fix double translation of subcats in advanced prefs

Lyndon Brown jnqnfe at gmail.com
Wed Sep 23 00:30:49 CEST 2020


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.
---
 .../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-devel mailing list