Commit 0662a800 authored by con's avatar con
Browse files

Handle read only files correctly when saving all modified files

We use the editor manager's way to save modified files now, so the
normal logic for read only files is applied, including the "cancel/save
as/open vcs/make writable" dialog.
Also fixes that it wasn't handled as a "cancel" if the user chooses to
cancel this dialog.

Task-number: QTCREATORBUG-3109
parent be3bb250
......@@ -638,46 +638,11 @@ QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
filesToSave = dia.itemsToSave();
}
bool yestoall = false;
Core::VCSManager *vcsManager = Core::ICore::instance()->vcsManager();
foreach (IFile *file, filesToSave) {
if (file->isReadOnly()) {
const QString directory = QFileInfo(file->fileName()).absolutePath();
if (IVersionControl *versionControl = vcsManager->findVersionControlForDirectory(directory))
versionControl->vcsOpen(file->fileName());
}
if (!file->isReadOnly() && !file->fileName().isEmpty()) {
blockFileChange(file);
const bool ok = file->save();
unblockFileChange(file);
if (!ok)
notSaved.append(file);
} else if (QFile::exists(file->fileName()) && !file->isSaveAsAllowed()) {
if (yestoall)
continue;
const QFileInfo fi(file->fileName());
switch (skipFailedPrompt(d->m_mainWindow, fi.fileName())) {
case QMessageBox::YesToAll:
yestoall = true;
break;
case QMessageBox::No:
if (cancelled)
*cancelled = true;
return filesToSave;
default:
break;
}
} else {
QString fileName = getSaveAsFileName(file);
bool ok = false;
if (!fileName.isEmpty()) {
blockFileChange(file);
ok = file->save(fileName);
file->checkPermissions();
unblockFileChange(file);
}
if (!ok)
notSaved.append(file);
if (!EditorManager::instance()->saveFile(file)) {
if (cancelled)
*cancelled = true;
notSaved.append(file);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment