diff options
author | Kai Köhne <kai.koehne@qt.io> | 2021-06-13 14:28:53 +0200 |
---|---|---|
committer | Kai Köhne <kai.koehne@qt.io> | 2021-06-21 13:39:50 +0200 |
commit | 0fd4f2a8def276aab0cb6465ba7b9ce75beb3a86 (patch) | |
tree | 8b487cfa1f4186b4e86f1305a83a66186b30c654 | |
parent | 6db694453636a0f7b8c4f51048f352da80d912d2 (diff) | |
download | qttools-0fd4f2a8def276aab0cb6465ba7b9ce75beb3a86.tar.gz |
Examples: Don't use QDir::separator() in internal paths
Documentation says:
You do not need to use this function to build file paths.
If you always use "/", Qt will translate your paths to conform
to the underlying operating system.
Change-Id: Iba62a197821b9abc819c3d333e44c9f1ed989898
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 8329ec476b3dc9bb7ffd17ee724b6b21c17e90ec)
-rw-r--r-- | examples/assistant/remotecontrol/remotecontrol.cpp | 11 | ||||
-rw-r--r-- | examples/assistant/simpletextviewer/assistant.cpp | 9 | ||||
-rw-r--r-- | examples/assistant/simpletextviewer/findfiledialog.cpp | 4 |
3 files changed, 13 insertions, 11 deletions
diff --git a/examples/assistant/remotecontrol/remotecontrol.cpp b/examples/assistant/remotecontrol/remotecontrol.cpp index 916a08efd..8b39aa6ff 100644 --- a/examples/assistant/remotecontrol/remotecontrol.cpp +++ b/examples/assistant/remotecontrol/remotecontrol.cpp @@ -98,11 +98,11 @@ void RemoteControl::on_launchButton_clicked() if (process->state() == QProcess::Running) return; - QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); + QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath); #if !defined(Q_OS_MAC) - app += QLatin1String("assistant"); + app += QLatin1String("/assistant"); #else - app += QLatin1String("Assistant.app/Contents/MacOS/Assistant"); + app += QLatin1String("/Assistant.app/Contents/MacOS/Assistant"); #endif ui.contentsCheckBox->setChecked(true); @@ -113,8 +113,9 @@ void RemoteControl::on_launchButton_clicked() args << QLatin1String("-enableRemoteControl"); process->start(app, args); if (!process->waitForStarted()) { - QMessageBox::critical(this, tr("Remote Control"), - tr("Could not start Qt Assistant from %1.").arg(app)); + QMessageBox::critical( + this, tr("Remote Control"), + tr("Could not start Qt Assistant from %1.").arg(QDir::toNativeSeparators(app))); return; } diff --git a/examples/assistant/simpletextviewer/assistant.cpp b/examples/assistant/simpletextviewer/assistant.cpp index ceda2c384..f6d7d3d33 100644 --- a/examples/assistant/simpletextviewer/assistant.cpp +++ b/examples/assistant/simpletextviewer/assistant.cpp @@ -115,11 +115,11 @@ bool Assistant::startAssistant() } if (m_process->state() != QProcess::Running) { - QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); + QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath); #ifndef Q_OS_DARWIN - app += QLatin1String("assistant"); + app += QLatin1String("/assistant"); #else - app += QLatin1String("Assistant.app/Contents/MacOS/Assistant"); + app += QLatin1String("/Assistant.app/Contents/MacOS/Assistant"); #endif const QString collectionDirectory = documentationDirectory(); @@ -135,7 +135,8 @@ bool Assistant::startAssistant() m_process->start(app, args); if (!m_process->waitForStarted()) { - showError(tr("Unable to launch Qt Assistant (%1): %2").arg(app, m_process->errorString())); + showError(tr("Unable to launch Qt Assistant (%1): %2") + .arg(QDir::toNativeSeparators(app), m_process->errorString())); return false; } } diff --git a/examples/assistant/simpletextviewer/findfiledialog.cpp b/examples/assistant/simpletextviewer/findfiledialog.cpp index 1eab5ad7f..51b184075 100644 --- a/examples/assistant/simpletextviewer/findfiledialog.cpp +++ b/examples/assistant/simpletextviewer/findfiledialog.cpp @@ -112,9 +112,9 @@ void FindFileDialog::openFile() return; QString fileName = item->text(0); - QString path = directoryComboBox->currentText() + QDir::separator(); + QString path = QDir(directoryComboBox->currentText()).filePath(fileName); - currentEditor->setContents(path + fileName); + currentEditor->setContents(path); close(); } |