Commit 0c96a5b6 authored by Jean-Philippe Andre's avatar Jean-Philippe Andre

Qt: try to fix #2430 (OpenUrl can crash).

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