vlc | branch: master | Filip Roséen <[email protected]> | Sat Feb 25 07:31:42 2017 +0100| [5f74ae9803b5fbc35792baa7a8d08202c9296454] | committer: Jean-Baptiste Kempf
gui/qt: extended_panels: refactor ChangeFiltersString The previous implementation was unnecessary complex, and by using the utilities available for string manipulation in Qt we can drastically reduce the lines of code. These changes also fixes an issue where a user would be unable to remove a video-filter if the command-line specified the same video-filter twice. Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f74ae9803b5fbc35792baa7a8d08202c9296454 --- modules/gui/qt/components/extended_panels.cpp | 58 ++++----------------------- 1 file changed, 7 insertions(+), 51 deletions(-) diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp index 4a3d7d3..c2c375d 100644 --- a/modules/gui/qt/components/extended_panels.cpp +++ b/modules/gui/qt/components/extended_panels.cpp @@ -259,61 +259,17 @@ void ExtVideo::clean() static char *ChangeFiltersString( struct intf_thread_t *p_intf, const char *psz_filter_type, const char *psz_name, bool b_add ) { - char *psz_parser, *psz_string; + char* psz_chain = config_GetPsz( p_intf, psz_filter_type ); - psz_string = config_GetPsz( p_intf, psz_filter_type ); + QString const chain = QString( psz_chain ? psz_chain : "" ); + QStringList list = chain.split( ':', QString::SplitBehavior::SkipEmptyParts ); - if( !psz_string ) psz_string = strdup( "" ); + if( b_add ) list << psz_name; + else list.removeAll( psz_name ); - psz_parser = strstr( psz_string, psz_name ); + free( psz_chain ); - if( b_add ) - { - if( !psz_parser ) - { - psz_parser = psz_string; - if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s", - psz_string, psz_name ) == -1 ) - { - free( psz_parser ); - return NULL; - } - free( psz_parser ); - } - else - { - free( psz_string ); - return NULL; - } - } - else - { - if( psz_parser ) - { - if( *( psz_parser + strlen( psz_name ) ) == ':' ) - { - memmove( psz_parser, psz_parser + strlen( psz_name ) + 1, - strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 ); - } - else - { - *psz_parser = '\0'; - } - - /* Remove trailing : : */ - size_t i_len = strlen( psz_string ); - if( i_len > 0 && *( psz_string + i_len - 1 ) == ':' ) - { - *( psz_string + i_len - 1 ) = '\0'; - } - } - else - { - free( psz_string ); - return NULL; - } - } - return psz_string; + return strdup( qtu( list.join( ':' ) ) ); } static void ChangeAFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
