Use FileChangeBlocker

Use FileChangeBlocker over expecting/unexpecting file changes manually.

Change-Id: I8428841f966d81be477260416c75e91dee795425
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2016-07-18 10:04:42 +02:00
parent 2ec82a2a93
commit 84f1466b01
5 changed files with 21 additions and 32 deletions

View File

@@ -1335,13 +1335,15 @@ bool QmakePriFileNode::setProVariable(const QString &var, const QStringList &val
void QmakePriFileNode::save(const QStringList &lines)
{
Core::DocumentManager::expectFileChange(m_projectFilePath.toString());
FileSaver saver(m_projectFilePath.toString(), QIODevice::Text);
saver.write(lines.join(QLatin1Char('\n')).toLocal8Bit());
saver.finalize(Core::ICore::mainWindow());
{
FileChangeBlocker changeGuard(m_projectFilePath.toString());
FileSaver saver(m_projectFilePath.toString(), QIODevice::Text);
saver.write(lines.join(QLatin1Char('\n')).toLocal8Bit());
saver.finalize(Core::ICore::mainWindow());
m_project->projectManager()->notifyChanged(m_projectFilePath);
}
m_project->projectManager()->notifyChanged(m_projectFilePath);
Core::DocumentManager::unexpectFileChange(m_projectFilePath.toString());
// This is a hack.
// We are saving twice in a very short timeframe, once the editor and once the ProFile.
// So the modification time might not change between those two saves.