Commit 58b5ae72 authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

Qt: do not free module config too early

Fix regression introduced in 95f14593

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: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent f1a205e4
......@@ -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 );
}
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment