]> git.sesse.net Git - vlc/commitdiff
Qt: try to fix #2430 (OpenUrl can crash).
authorJean-Philippe Andre <jpeg@via.ecp.fr>
Sat, 24 Jan 2009 14:23:42 +0000 (15:23 +0100)
committerJean-Philippe Andre <jpeg@via.ecp.fr>
Sat, 24 Jan 2009 14:27:06 +0000 (15:27 +0100)
+ Remove this->
+ Remove toNativeSeparators

modules/gui/qt4/dialogs/openurl.cpp
modules/gui/qt4/dialogs_provider.cpp

index 5fa3e7b19b8025ab5925376b82877a5910defcef..49a791b15478af2d230952ea36390064eb001b7b 100644 (file)
@@ -38,6 +38,8 @@
 #include <QFile>
 #include <QLabel>
 
+#include <assert.h>
+
 OpenUrlDialog *OpenUrlDialog::instance = NULL;
 
 OpenUrlDialog* OpenUrlDialog::getInstance( QWidget *parent,
@@ -54,10 +56,10 @@ OpenUrlDialog* OpenUrlDialog::getInstance( QWidget *parent,
 
 OpenUrlDialog::OpenUrlDialog( QWidget *parent,
                               intf_thread_t *_p_intf,
-                              bool bClipboard ) : QVLCDialog( parent, _p_intf )
+                              bool _bClipboard ) :
+        QVLCDialog( parent, _p_intf ), bClipboard( _bClipboard )
 {
-    this->bClipboard = bClipboard;
-    this->setWindowTitle( qtr( "Open URL" ) );
+    setWindowTitle( qtr( "Open URL" ) );
 
     /* Buttons */
     QPushButton *but;
@@ -78,9 +80,9 @@ OpenUrlDialog::OpenUrlDialog( QWidget *parent,
                                     "to the media you want to play"),
                                this );
 
-    this->setToolTip( qtr( "If your clipboard contains a valid URL\n"
-                           "or the path to a file on your computer,\n"
-                           "it will be automatically selected." ) );
+    setToolTip( qtr( "If your clipboard contains a valid URL\n"
+                     "or the path to a file on your computer,\n"
+                     "it will be automatically selected." ) );
 
     /* Layout */
     QVBoxLayout *vlay = new QVBoxLayout( this );
@@ -136,11 +138,11 @@ void OpenUrlDialog::showEvent( QShowEvent *ev )
     if( bClipboard )
     {
         QClipboard *clipboard = QApplication::clipboard();
-        const QMimeData *data = clipboard->mimeData( QClipboard::Selection );
-        QString txt = data->text().trimmed();
+        assert( clipboard != NULL );
+        QString txt = clipboard->text( QClipboard::Selection ).trimmed();
 
         if( txt.isEmpty() || ( !txt.contains("://") && !QFile::exists(txt) ) )
-            txt = clipboard->mimeData()->text().trimmed();
+            txt = clipboard->text( QClipboard::Clipboard ).trimmed();
 
         if( txt.contains( "://" ) || QFile::exists( txt ) )
             edit->setText( txt );
index 65bc820ca244c5f9f1f000684a225d8af7ca9b88..dd67c06bdab809127841cfd5c979c3dfd8e81a16 100644 (file)
@@ -438,13 +438,12 @@ void DialogsProvider::openUrlDialog()
         QString url = oud->url();
         if( !url.isEmpty() )
         {
-            playlist_Add( THEPL, qtu( toNativeSeparators( url ) ),
+            playlist_Add( THEPL, qtu( url ),
                           NULL, !oud->shouldEnqueue() ?
                                   ( PLAYLIST_APPEND | PLAYLIST_GO )
                                 : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
                           PLAYLIST_END, true, false );
-            RecentsMRL::getInstance( p_intf )->addRecent(
-                                     toNativeSeparators( url ) );
+            RecentsMRL::getInstance( p_intf )->addRecent( url );
         }
     }
 }