[vlc-commits] [Git][videolan/vlc][master] doc: QtPlayer: fix file opening on Windows

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Mar 23 14:53:13 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
f7d4afc8 by Simon Latapie at 2023-03-23T14:36:25+00:00
doc: QtPlayer: fix file opening on Windows

Using a raw path from the QFileDialog can lead to wrong native
separators in the provided string.
Using URLs instead of paths should be more cross-platform compliant.

- - - - -


1 changed file:

- doc/libvlc/QtPlayer/player.cpp


Changes:

=====================================
doc/libvlc/QtPlayer/player.cpp
=====================================
@@ -17,6 +17,7 @@
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QFileDialog>
+#include <QUrl>
 
 Mwindow::Mwindow() {
     vlcPlayer = NULL;
@@ -125,14 +126,14 @@ void Mwindow::initUI() {
 void Mwindow::openFile() {
 
     /* The basic file-select box */
-    QString fileOpen = QFileDialog::getOpenFileName(this, tr("Load a file"), "~");
+    QUrl url = QFileDialog::getOpenFileUrl(this, tr("Load a file"));
 
     /* Stop if something is playing */
     if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer))
         stop();
 
     /* Create a new Media */
-    libvlc_media_t *vlcMedia = libvlc_media_new_path(qtu(fileOpen));
+    libvlc_media_t *vlcMedia = libvlc_media_new_location(qtu(url.toString(QUrl::FullyEncoded)));
     if (!vlcMedia)
         return;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/f7d4afc821735e53d18c454debeeb8da14741a55

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/f7d4afc821735e53d18c454debeeb8da14741a55
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list