Use new FilePath::setPermissions in a few cases

Change-Id: Ic7122c86c273a87134ea8cd1a00b1bbdf5035971
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-08-18 13:27:26 +02:00
parent 9966cc4bcc
commit 6e8c4aa835
4 changed files with 11 additions and 14 deletions

View File

@@ -52,17 +52,20 @@
using namespace ProjectExplorer;
using namespace Utils;
namespace CppTools {
namespace Tests {
static bool closeEditorsWithoutGarbageCollectorInvocation(const QList<Core::IEditor *> &editors)
{
CppTools::CppModelManager::instance()->enableGarbageCollector(false);
CppModelManager::instance()->enableGarbageCollector(false);
const bool closeEditorsSucceeded = Core::EditorManager::closeEditors(editors, false);
CppTools::CppModelManager::instance()->enableGarbageCollector(true);
CppModelManager::instance()->enableGarbageCollector(true);
return closeEditorsSucceeded;
}
static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QString> &filePaths)
{
foreach (const QString &filePath, filePaths) {
for (const QString &filePath : filePaths) {
if (!snapshot.contains(filePath)) {
qWarning() << "Missing file in snapshot:" << qPrintable(filePath);
return false;
@@ -71,9 +74,6 @@ static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QSt
return true;
}
namespace CppTools {
namespace Tests {
TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
: m_fileName(QString::fromUtf8(fileName))
, m_source(QString::fromUtf8(source))
@@ -214,7 +214,7 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QSt
t.start();
QList<CPlusPlus::Document::Ptr> result;
foreach (const QString &filePath, filePaths) {
for (const QString &filePath : filePaths) {
forever {
if (CPlusPlus::Document::Ptr document = globalSnapshot().document(filePath)) {
result.append(document);
@@ -333,8 +333,7 @@ static bool copyRecursively(const QString &sourceDirPath,
// Copied files from Qt resources are read-only. Make them writable
// so that their parent directory can be removed without warnings.
QFile file(targetPath.toString());
return file.setPermissions(file.permissions() | QFile::WriteUser);
return targetPath.setPermissions(targetPath.permissions() | QFile::WriteUser);
};
return Utils::FileUtils::copyRecursively(Utils::FilePath::fromString(sourceDirPath),