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.
This commit is contained in:
mae
2009-05-08 17:57:27 +02:00
committed by con
parent 6589b04879
commit 9dbac2320e
4 changed files with 25 additions and 22 deletions

View File

@@ -678,9 +678,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())
@@ -1176,23 +1176,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;
file->checkPermissions();
m_d->m_core->fileManager()->blockFileChange(file);
success = file->save(fileName);
m_d->m_core->fileManager()->unblockFileChange(file);
}
if (file->isReadOnly() || fileName.isEmpty())
return saveFileAs(editor);
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;
}
@@ -1214,7 +1226,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();
@@ -1283,6 +1295,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());

View File

@@ -383,6 +383,7 @@ QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
if (!fileName.isEmpty()) {
blockFileChange(file);
ok = file->save(fileName);
file->checkPermissions();
unblockFileChange(file);
}
if (!ok)

View File

@@ -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;
}

View File

@@ -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;
}