[vlc-devel] commit: Qt: correctly split options and escape ':' so if your dshow devices or your subtitle contains a " :" in the name, it is correctly opened. (Jean-Baptiste Kempf )

git version control git at videolan.org
Sun Mar 15 18:21:49 CET 2009


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Mar 15 17:57:37 2009 +0100| [319a10e66abb7fdd2c43026e1d3ae2b2316c2212] | committer: Jean-Baptiste Kempf 

Qt: correctly split options and escape ':' so if your dshow devices or your subtitle contains a " :" in the name, it is correctly opened.

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

 modules/gui/qt4/components/open_panels.cpp |   10 ++++++----
 modules/gui/qt4/dialogs/open.cpp           |    5 +++--
 modules/gui/qt4/dialogs_provider.cpp       |    2 +-
 modules/gui/qt4/util/qt_dirs.hpp           |    8 ++++++++
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 4c2fcd3..04e776b 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -192,7 +192,7 @@ void FileOpenPanel::updateMRL()
         fileList << ui.fileListWidg->item( i )->text();
 
     if( ui.subCheckBox->isChecked() &&  !ui.subInput->text().isEmpty() ) {
-        mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
+        mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
         int align = ui.alignSubComboBox->itemData(
                     ui.alignSubComboBox->currentIndex() ).toInt();
         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
@@ -1057,8 +1057,10 @@ void CaptureOpenPanel::updateMRL()
         break;
     case DSHOW_DEVICE:
         fileList << "dshow://";
-        mrl+= " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
-        mrl+= " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
+        mrl+= " :dshow-vdev=" +
+            colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
+        mrl+= " :dshow-adev=" +
+            colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
         if( dshowVSizeLine->isModified() )
             mrl += " :dshow-size=" + dshowVSizeLine->text();
         break;
@@ -1252,7 +1254,7 @@ void CaptureOpenPanel::advancedDialog()
                 case CONFIG_ITEM_FILE:
                 case CONFIG_ITEM_DIRECTORY:
                 case CONFIG_ITEM_MODULE:
-                    tempMRL += QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
+                    tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
                     break;
                 case CONFIG_ITEM_INTEGER:
                     tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp
index 1646093..db1e67f 100644
--- a/modules/gui/qt4/dialogs/open.cpp
+++ b/modules/gui/qt4/dialogs/open.cpp
@@ -30,6 +30,7 @@
 #include "dialogs_provider.hpp"
 
 #include "recents.hpp"
+#include "util/qt_dirs.hpp"
 
 #include <QTabWidget>
 #include <QGridLayout>
@@ -352,12 +353,12 @@ void OpenDialog::finish( bool b_enqueue = false )
         if( i == 0 )
         {
             /* Take options from the UI, not from what we stored */
-            QStringList optionsList = ui.advancedLineInput->text().split( ":" );
+            QStringList optionsList = ui.advancedLineInput->text().split( " :" );
 
             /* Insert options */
             for( int j = 0; j < optionsList.size(); j++ )
             {
-                QString qs = optionsList[j].trimmed();
+                QString qs = colon_unescape( optionsList[j] );
                 if( !qs.isEmpty() )
                 {
                     input_item_AddOption( p_input, qtu( qs ),
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 2c95d90..0adf974 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -611,7 +611,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
         /* Add normal Options */
         for( int j = 0; j < options.size(); j++ )
         {
-            QString qs = options[j].trimmed();
+            QString qs = colon_unescape( options[j] );
             if( !qs.isEmpty() )
             {
                 input_item_AddOption( p_input, qtu( qs ),
diff --git a/modules/gui/qt4/util/qt_dirs.hpp b/modules/gui/qt4/util/qt_dirs.hpp
index c2af9ce..113eb0d 100644
--- a/modules/gui/qt4/util/qt_dirs.hpp
+++ b/modules/gui/qt4/util/qt_dirs.hpp
@@ -47,5 +47,13 @@ static inline QString removeTrailingSlash( QString s )
 
 #define toNativeSepNoSlash( a ) toNativeSeparators( removeTrailingSlash( a ) )
 
+static inline QString colon_escape( QString s )
+{
+    return s.replace( ":", "\\:" );
+}
+static inline QString colon_unescape( QString s )
+{
+    return s.replace( "\\:", ":" ).trimmed();
+}
 #endif
 




More information about the vlc-devel mailing list