Commit 9b82d98e authored by mae's avatar mae
Browse files

some work on the save-modified-files logic. We no longer rely

on QFileInfo to tell us that a file is not writable, but accept
that the attempt to save a file might actually fail (:-) ). This
solves the NT network domain issue without the insane slowness.

The stuff needs more work. We do not have any UI for failing save
operations when closing creator (other than it doesn't close). Bad.
parent 3a8fab25
......@@ -698,9 +698,9 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
if (cancelled)
return false;
if (!list.isEmpty()) {
closingFailed = true;
QSet<IEditor*> skipSet = editorsForFiles(list).toSet();
acceptedEditors = acceptedEditors.toSet().subtract(skipSet).toList();
closingFailed = false;
}
}
if (acceptedEditors.isEmpty())
......@@ -1203,23 +1203,35 @@ bool EditorManager::saveFile(IEditor *editor)
file->checkPermissions();
const QString &fileName = file->fileName();
if (!fileName.isEmpty() && file->isReadOnly()) {
if (fileName.isEmpty())
return saveFileAs(editor);
bool success = false;
// try saving, no matter what isReadOnly tells us
m_d->m_core->fileManager()->blockFileChange(file);
success = file->save(fileName);
m_d->m_core->fileManager()->unblockFileChange(file);
if (!success) {
MakeWritableResult answer =
makeEditorWritable(editor);
if (answer == Failed)
return false;
if (answer == SavedAs)
return true;
}
if (file->isReadOnly() || fileName.isEmpty())
return saveFileAs(editor);
file->checkPermissions();
m_d->m_core->fileManager()->blockFileChange(file);
success = file->save(fileName);
m_d->m_core->fileManager()->unblockFileChange(file);
}
m_d->m_core->fileManager()->blockFileChange(file);
const bool success = file->save(fileName);
m_d->m_core->fileManager()->unblockFileChange(file);
if (success)
m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName());
return success;
}
......@@ -1241,7 +1253,7 @@ EditorManager::ReadOnlyAction
QPushButton *saveAsButton = 0;
if (displaySaveAsButton)
msgBox.addButton(QObject::tr("Save as ..."), QMessageBox::ActionRole);
saveAsButton = msgBox.addButton(QObject::tr("Save as ..."), QMessageBox::ActionRole);
msgBox.setDefaultButton(sccButton ? sccButton : makeWritableButton);
msgBox.exec();
......@@ -1310,6 +1322,7 @@ bool EditorManager::saveFileAs(IEditor *editor)
m_d->m_core->fileManager()->blockFileChange(editor->file());
const bool success = editor->file()->save(absoluteFilePath);
m_d->m_core->fileManager()->unblockFileChange(editor->file());
editor->file()->checkPermissions();
if (success)
m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName());
......
......@@ -394,6 +394,7 @@ QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
if (!fileName.isEmpty()) {
blockFileChange(file);
ok = file->save(fileName);
file->checkPermissions();
unblockFileChange(file);
}
if (!ok)
......
......@@ -354,8 +354,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
// Save opened files
bool cancelled;
fileManager()->saveModifiedFiles(fileManager()->modifiedFiles(), &cancelled);
if (cancelled) {
QList<IFile*> notSaved = fileManager()->saveModifiedFiles(fileManager()->modifiedFiles(), &cancelled);
if (cancelled || !notSaved.isEmpty()) {
event->ignore();
return;
}
......
......@@ -163,18 +163,7 @@ void BaseTextDocument::checkPermissions()
{
if (!m_fileName.isEmpty()) {
const QFileInfo fi(m_fileName);
#ifdef Q_OS_WIN
// Check for permissions on NTFS file systems
qt_ntfs_permission_lookup++;
#endif
m_fileIsReadOnly = !fi.isWritable();
#ifdef Q_OS_WIN
qt_ntfs_permission_lookup--;
#endif
} else {
m_fileIsReadOnly = false;
}
......
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