From f7d4afc821735e53d18c454debeeb8da14741a55 Mon Sep 17 00:00:00 2001 From: Simon Latapie Date: Fri, 17 Mar 2023 16:54:48 +0100 Subject: [PATCH] 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. --- doc/libvlc/QtPlayer/player.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/libvlc/QtPlayer/player.cpp b/doc/libvlc/QtPlayer/player.cpp index 4dae3d6dc4..e7bc562745 100644 --- a/doc/libvlc/QtPlayer/player.cpp +++ b/doc/libvlc/QtPlayer/player.cpp @@ -17,6 +17,7 @@ #include #include #include +#include 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;