From 828440b0ff7e27564c56122c978aeb1b70cabe9c Mon Sep 17 00:00:00 2001 From: Andrii Semkiv Date: Fri, 6 Sep 2024 16:01:21 +0200 Subject: [PATCH] BinEditor: Replace FilePath::toString Replace occurrences of FilePath::toString with more sensible alternatives. Change-Id: Ic6a313f6dbd75c39f7c3054526f232c07c2023d5 Reviewed-by: Marcus Tillmanns --- src/plugins/bineditor/bineditorplugin.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 09566d1b846..4daa5a2201a 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -618,12 +618,14 @@ void BinEditorDocument::setModified(bool modified) bool BinEditorDocument::save(QString *errorString, const FilePath &oldFilePath, const FilePath &newFilePath) { if (oldFilePath != newFilePath) { + // Get a unique temporary file name FilePath tmpName; { - QTemporaryFile tmp(newFilePath.toString() + QLatin1String("_XXXXXX.new")); - if (!tmp.open()) + const auto result = TemporaryFilePath::create( + newFilePath.stringAppended("_XXXXXX.new")); + if (!result) return false; - tmpName = FilePath::fromString(tmp.fileName()); + tmpName = (*result)->filePath(); } if (!oldFilePath.copyFile(tmpName)) return false;