aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/resourceeditor
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-05-23 23:41:14 +0300
committerOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-05-23 23:41:40 +0300
commit8430da3bf7f495ecfe84b36421d4da801cf0f6a5 (patch)
tree805d10955fa65e635077038f5fb54bb0e0b168eb /src/plugins/resourceeditor
parentd42e867f441f90bf127c3fc8571b862bb4a9596a (diff)
parent7482d8a15239ee1cb289953f7d8ce167583b6261 (diff)
Merge remote-tracking branch 'origin/4.3' into master
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r--src/plugins/resourceeditor/resourcenode.cpp18
-rw-r--r--src/plugins/resourceeditor/resourcenode.h2
2 files changed, 8 insertions, 12 deletions
diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp
index 20f67b2eec..cb7b5be887 100644
--- a/src/plugins/resourceeditor/resourcenode.cpp
+++ b/src/plugins/resourceeditor/resourcenode.cpp
@@ -146,7 +146,6 @@ static bool addFilesToResource(const FileName &resourceFile,
}
}
- FileChangeBlocker changeGuard(resourceFile.toString());
file.save();
return true;
@@ -270,12 +269,15 @@ ResourceTopLevelNode::ResourceTopLevelNode(const FileName &filePath, bool genera
{
setIsGenerated(generated);
setIcon(FileIconProvider::icon(filePath.toString()));
- if (contents.isEmpty()) {
- m_document = new ResourceFileWatcher(this);
- DocumentManager::addDocument(m_document);
+ setPriority(Node::DefaultFilePriority);
+ if (!filePath.isEmpty()) {
+ QFileInfo fi = filePath.toFileInfo();
+ if (fi.isFile() && fi.isReadable()) {
+ m_document = new ResourceFileWatcher(this);
+ DocumentManager::addDocument(m_document);
+ }
} else {
m_contents = contents;
- m_document = nullptr;
}
FileName base = parent->filePath();
@@ -416,7 +418,6 @@ bool ResourceTopLevelNode::addPrefix(const QString &prefix, const QString &lang)
int index = file.addPrefix(prefix, lang);
if (index == -1)
return false;
- FileChangeBlocker changeGuard(filePath().toString());
file.save();
return true;
@@ -431,7 +432,6 @@ bool ResourceTopLevelNode::removePrefix(const QString &prefix, const QString &la
if (file.prefix(i) == prefix
&& file.lang(i) == lang) {
file.removePrefix(i);
- FileChangeBlocker changeGuard(filePath().toString());
file.save();
return true;
}
@@ -456,7 +456,6 @@ bool ResourceTopLevelNode::removeNonExistingFiles()
}
}
- FileChangeBlocker changeGuard(filePath().toString());
file.save();
return true;
}
@@ -551,7 +550,6 @@ bool ResourceFolderNode::removeFiles(const QStringList &filePaths, QStringList *
file.removeFile(index, j);
--j;
}
- FileChangeBlocker changeGuard(m_topLevelNode->filePath().toString());
file.save();
return true;
@@ -590,7 +588,6 @@ bool ResourceFolderNode::renameFile(const QString &filePath, const QString &newF
for (int j = 0; j < file.fileCount(index); ++j) {
if (file.file(index, j) == filePath) {
file.replaceFile(index, j, newFilePath);
- FileChangeBlocker changeGuard(m_topLevelNode->filePath().toString());
file.save();
return true;
}
@@ -611,7 +608,6 @@ bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang
if (!file.replacePrefixAndLang(index, prefix, lang))
return false;
- FileChangeBlocker changeGuard(m_topLevelNode->filePath().toString());
file.save();
return true;
}
diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h
index f1377eaa14..e2f84e005a 100644
--- a/src/plugins/resourceeditor/resourcenode.h
+++ b/src/plugins/resourceeditor/resourcenode.h
@@ -56,7 +56,7 @@ public:
QString contents() const { return m_contents; }
private:
- Internal::ResourceFileWatcher *m_document;
+ Internal::ResourceFileWatcher *m_document = nullptr;
QString m_contents;
};