summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/utils/fileutils.cpp2
-rw-r--r--src/libs/utils/savefile.cpp14
-rw-r--r--src/libs/utils/savefile.h10
-rw-r--r--src/plugins/cppeditor/cppmodelmanager.cpp2
4 files changed, 14 insertions, 14 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp
index 53e5bd2d0b..e44102f4c7 100644
--- a/src/libs/utils/fileutils.cpp
+++ b/src/libs/utils/fileutils.cpp
@@ -192,7 +192,7 @@ FileSaver::FileSaver(const FilePath &filePath, QIODevice::OpenMode mode)
m_file.reset(new QFile{filePath.path()});
m_isSafe = false;
} else {
- m_file.reset(new SaveFile{filePath.path()});
+ m_file.reset(new SaveFile(filePath));
m_isSafe = true;
}
if (!m_file->open(QIODevice::WriteOnly | mode)) {
diff --git a/src/libs/utils/savefile.cpp b/src/libs/utils/savefile.cpp
index 9bd840f48d..4cf579ac0b 100644
--- a/src/libs/utils/savefile.cpp
+++ b/src/libs/utils/savefile.cpp
@@ -20,8 +20,8 @@ namespace Utils {
static QFile::Permissions m_umask;
-SaveFile::SaveFile(const QString &filename) :
- m_finalFileName(filename)
+SaveFile::SaveFile(const FilePath &filePath) :
+ m_finalFilePath(filePath)
{
}
@@ -32,16 +32,16 @@ SaveFile::~SaveFile()
bool SaveFile::open(OpenMode flags)
{
- QTC_ASSERT(!m_finalFileName.isEmpty(), return false);
+ QTC_ASSERT(!m_finalFilePath.isEmpty(), return false);
- QFile ofi(m_finalFileName);
+ QFile ofi(m_finalFilePath.toFSPathString());
// Check whether the existing file is writable
if (ofi.exists() && !ofi.open(QIODevice::ReadWrite)) {
setErrorString(ofi.errorString());
return false;
}
- m_tempFile = std::make_unique<QTemporaryFile>(m_finalFileName);
+ m_tempFile = std::make_unique<QTemporaryFile>(m_finalFilePath.toFSPathString());
m_tempFile->setAutoRemove(false);
if (!m_tempFile->open())
return false;
@@ -100,7 +100,7 @@ bool SaveFile::commit()
return false;
}
- QString finalFileName = FilePath::fromString(m_finalFileName).resolveSymlinks().toString();
+ QString finalFileName = m_finalFilePath.resolveSymlinks().toString();
#ifdef Q_OS_WIN
// Release the file lock
@@ -200,4 +200,4 @@ void SaveFile::initializeUmask()
#endif
}
-} // namespace Utils
+} // Utils
diff --git a/src/libs/utils/savefile.h b/src/libs/utils/savefile.h
index 14d62fdf06..75990bffea 100644
--- a/src/libs/utils/savefile.h
+++ b/src/libs/utils/savefile.h
@@ -5,6 +5,8 @@
#include "utils_global.h"
+#include "filepath.h"
+
#include <QFile>
QT_BEGIN_NAMESPACE
@@ -17,10 +19,8 @@ namespace Utils {
class QTCREATOR_UTILS_EXPORT SaveFile : public QFile
{
- Q_OBJECT
-
public:
- explicit SaveFile(const QString &filename);
+ explicit SaveFile(const FilePath &filePath);
~SaveFile() override;
bool open(OpenMode flags = QIODevice::WriteOnly) override;
@@ -31,9 +31,9 @@ public:
static void initializeUmask();
private:
- const QString m_finalFileName;
+ const FilePath m_finalFilePath;
std::unique_ptr<QTemporaryFile> m_tempFile;
bool m_finalized = true;
};
-} // namespace Utils
+} // Utils
diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp
index c80abecbac..f8dc3173c2 100644
--- a/src/plugins/cppeditor/cppmodelmanager.cpp
+++ b/src/plugins/cppeditor/cppmodelmanager.cpp
@@ -358,7 +358,7 @@ void CppModelManager::showPreprocessedFile(bool inNextSplit)
};
static const auto saveAndOpen = [](const FilePath &filePath, const QByteArray &contents,
bool inNextSplit) {
- SaveFile f(filePath.toString());
+ SaveFile f(filePath);
if (!f.open()) {
showError(Tr::tr("Failed to open output file \"%1\".").arg(filePath.toUserOutput()));
return;