[vlc-commits] Qt: do not free module config too early

Edward Wang git at videolan.org
Mon Aug 19 11:44:10 CEST 2013


vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Aug 18 23:17:16 2013 -0400| [58b5ae72eff59365220024c970a8b44224b42c3d] | committer: Jean-Baptiste Kempf

Qt: do not free module config too early

Fix regression introduced in 95f145933a553e082eb42577d72dbf8bdea9972b

ConfigControl::getName() uses memory of p_item which is a part of p_config memory. This was causing a crash when trying to save the preferences, as the constructor had already destroyed it upon creation.

Instead, free the p_config memory on the destructor, which is automatically called when the dialog closes, saved or cancelled. Verified to not leak any memory.

Close #9214

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/complete_preferences.cpp |   13 +++++++------
 modules/gui/qt4/components/complete_preferences.hpp |    1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/complete_preferences.cpp b/modules/gui/qt4/components/complete_preferences.cpp
index 8269212..c4e98f7 100644
--- a/modules/gui/qt4/components/complete_preferences.cpp
+++ b/modules/gui/qt4/components/complete_preferences.cpp
@@ -580,7 +580,9 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
  * The Panel
  *********************************************************************/
 AdvPrefsPanel::AdvPrefsPanel( QWidget *_parent ) : QWidget( _parent )
-{}
+{
+    p_config = NULL;
+}
 
 AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                         PrefsItemData * data ) :
@@ -588,6 +590,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 {
     /* Find our module */
     module_t *p_module = NULL;
+    p_config = NULL;
     if( data->i_type == PrefsItemData::TYPE_CATEGORY )
         return;
     else if( data->i_type == PrefsItemData::TYPE_MODULE )
@@ -599,8 +602,8 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     }
 
     unsigned confsize;
-    module_config_t *const p_config = module_config_get( p_module, &confsize ),
-                    *p_item = p_config,
+    p_config = module_config_get( p_module, &confsize );
+    module_config_t *p_item = p_config,
                     *p_end = p_config + confsize;
 
     if( data->i_type == PrefsItemData::TYPE_SUBCATEGORY ||
@@ -730,8 +733,6 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     scroller->setWidgetResizable( true );
     global_layout->addWidget( scroller );
     setLayout( global_layout );
-
-    module_config_free( p_config );
 }
 
 void AdvPrefsPanel::apply()
@@ -746,5 +747,5 @@ void AdvPrefsPanel::clean()
 AdvPrefsPanel::~AdvPrefsPanel()
 {
     qDeleteAll( controls ); controls.clear();
+    module_config_free( p_config );
 }
-
diff --git a/modules/gui/qt4/components/complete_preferences.hpp b/modules/gui/qt4/components/complete_preferences.hpp
index acf4823..3b32c3a 100644
--- a/modules/gui/qt4/components/complete_preferences.hpp
+++ b/modules/gui/qt4/components/complete_preferences.hpp
@@ -100,6 +100,7 @@ public:
     void apply();
     void clean();
 private:
+    module_config_t *p_config;
     intf_thread_t *p_intf;
     QList<ConfigControl *> controls;
     QVBoxLayout *global_layout;



More information about the vlc-commits mailing list