vlc | branch: master | Filip Roséen <[email protected]> | Sat Feb 25 07:31:43 2017 +0100| [ac96c33de43d0780f7c20f643f3774a2bd7e95d4] | committer: Jean-Baptiste Kempf
gui/qt: extended_panels: change return-type of ChangeFiltersString By returning a QString instead of a heap-allocated c-style string we reduce complexity, and hopefully increase correctness as there is less manual memory-management to worry about. Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac96c33de43d0780f7c20f643f3774a2bd7e95d4 --- modules/gui/qt/components/extended_panels.cpp | 30 ++++++++------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp index c2c375d..837932e 100644 --- a/modules/gui/qt/components/extended_panels.cpp +++ b/modules/gui/qt/components/extended_panels.cpp @@ -52,7 +52,7 @@ #include <vlc_modules.h> #include <vlc_plugin.h> -static char *ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_filter_type, const char *psz_name, bool b_add ); +static QString ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_filter_type, const char *psz_name, bool b_add ); static void ChangeAFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add ); static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add ); @@ -257,7 +257,7 @@ void ExtVideo::clean() ui.cropRightPx->setValue( 0 ); } -static char *ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_filter_type, const char *psz_name, bool b_add ) +static QString ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_filter_type, const char *psz_name, bool b_add ) { char* psz_chain = config_GetPsz( p_intf, psz_filter_type ); @@ -269,13 +269,11 @@ static char *ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_ free( psz_chain ); - return strdup( qtu( list.join( ':' ) ) ); + return list.join( ':' ); } static void ChangeAFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add ) { - char *psz_string; - module_t *p_obj = module_find( psz_name ); if( !p_obj ) { @@ -283,13 +281,8 @@ static void ChangeAFiltersString( struct intf_thread_t *p_intf, const char *psz_ return; } - psz_string = ChangeFiltersString( p_intf, "audio-filter", psz_name, b_add ); - if( !psz_string ) - return; - - config_PutPsz( p_intf, "audio-filter", psz_string ); - - free( psz_string ); + QString result = ChangeFiltersString( p_intf, "audio-filteR", psz_name, b_add ); + config_PutPsz( p_intf, "audio-filter", qtu( result ) ); } static const char* GetVFilterType( struct intf_thread_t *p_intf, const char *psz_name ) @@ -318,33 +311,28 @@ static const char* GetVFilterType( struct intf_thread_t *p_intf, const char *psz static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add ) { - char *psz_string; const char *psz_filter_type = GetVFilterType( p_intf, psz_name ); - psz_string = ChangeFiltersString( p_intf, psz_filter_type, psz_name, b_add ); - if( !psz_string ) - return; + QString result = ChangeFiltersString( p_intf, psz_filter_type, psz_name, b_add ); /* Vout is not kept, so put that in the config */ - config_PutPsz( p_intf, psz_filter_type, psz_string ); + config_PutPsz( p_intf, psz_filter_type, qtu( result ) ); /* Try to set on the fly */ if( !strcmp( psz_filter_type, "video-splitter" ) ) { playlist_t *p_playlist = THEPL; - var_SetString( p_playlist, psz_filter_type, psz_string ); + var_SetString( p_playlist, psz_filter_type, qtu( result ) ); } else { vout_thread_t *p_vout = THEMIM->getVout(); if( p_vout ) { - var_SetString( p_vout, psz_filter_type, psz_string ); + var_SetString( p_vout, psz_filter_type, qtu( result ) ); vlc_object_release( p_vout ); } } - - free( psz_string ); } void ExtVideo::updateFilters() _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
