diff --git a/NEWS.md b/NEWS.md index 07e3313c8..16b093555 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,11 @@ stripped anymore during the process of ensuring the destination file name is unique. Only those suffixes added automatically in prior attempts to make the file name unique will be removed. Fixes #2521. +* MKVToolNix GUI: multiplexer: Windows: the GUI will let the user change the + drive letter part of the destination file name freely again and only verify + its validity right before starting to mux/adding to the job queue. Before it + tried to force that into something valid, often resulting in unintentional + paths (such as "C:\users\…\DC\files\…"). Fixes #2527. # Version 32.0.0 "Astral Progressions" 2019-03-12 diff --git a/src/mkvtoolnix-gui/merge/output.cpp b/src/mkvtoolnix-gui/merge/output.cpp index dc439b089..f0488ce06 100644 --- a/src/mkvtoolnix-gui/merge/output.cpp +++ b/src/mkvtoolnix-gui/merge/output.cpp @@ -342,13 +342,12 @@ Tab::onTitleChanged(QString newValue) { void Tab::setDestination(QString const &newValue) { - QString prefix; #if defined(SYS_WINDOWS) - if (newValue.startsWith(Q(":"))) - prefix = Q(":"); + if (!newValue.contains(QRegularExpression{Q("^[a-zA-Z]:[\\\\/]|^\\\\\\\\.+\\.+")})) + return; #endif - m_config.m_destination = QDir::toNativeSeparators(prefix + Util::removeInvalidPathCharacters(newValue)); + m_config.m_destination = QDir::toNativeSeparators(Util::removeInvalidPathCharacters(newValue)); if (!m_config.m_destination.isEmpty()) { auto &settings = Util::Settings::get(); settings.m_lastOutputDir = QFileInfo{ newValue }.absoluteDir(); @@ -359,7 +358,7 @@ Tab::setDestination(QString const &newValue) { if (m_config.m_destination == newValue) return; - auto newPosition = std::max(ui->output->cursorPosition(), 1) - 1; + auto newPosition = ui->output->cursorPosition(); ui->output->setText(m_config.m_destination); ui->output->setCursorPosition(newPosition); } diff --git a/src/mkvtoolnix-gui/merge/tab.cpp b/src/mkvtoolnix-gui/merge/tab.cpp index 718cb09a6..1e01466a2 100644 --- a/src/mkvtoolnix-gui/merge/tab.cpp +++ b/src/mkvtoolnix-gui/merge/tab.cpp @@ -335,12 +335,21 @@ Tab::retranslateUi() { bool Tab::isReadyForMerging() { - if (m_config.m_destination.isEmpty()) { + auto destination = QDir::toNativeSeparators(ui->output->text()); + + if (destination.isEmpty()) { Util::MessageBox::critical(this)->title(QY("Cannot start multiplexing")).text(QY("You have to set the destination file name before you can start multiplexing or add a job to the job queue.")).exec(); return false; } - if (m_config.m_destination != Util::removeInvalidPathCharacters(m_config.m_destination)) { + auto destinationValid = destination == Util::removeInvalidPathCharacters(destination); + +#if defined(SYS_WINDOWS) + if (destinationValid) + destinationValid = destination.contains(QRegularExpression{Q("^[a-zA-Z]:[\\\\/]|^\\\\\\\\.+\\.+")}); +#endif // SYS_WINDOWS + + if (!destinationValid) { Util::MessageBox::critical(this)->title(QY("Cannot start multiplexing")).text(QY("The destination file name is invalid and must be fixed before you can start multiplexing or add a job to the job queue.")).exec(); return false; }