From 8e8168fc5c006a073fa00cc34971dc156b523460 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 8 Mar 2012 08:42:29 +0100 Subject: [PATCH] Fix reloading behavior of image viewer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image viewer is not able to save, so we should not ask. Task-number: QTCREATORBUG-5966 Change-Id: I947520d7450704abda8395e8aaae56dfe7842328 Reviewed-by: Robert Löhning Reviewed-by: Eike Ziller --- src/plugins/coreplugin/documentmanager.cpp | 8 ++++++-- src/plugins/imageviewer/imageviewerfile.cpp | 9 +++++++++ src/plugins/imageviewer/imageviewerfile.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index c170d248dc6..878c2fb612f 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -667,7 +667,8 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, } *isReadOnly = false; } - QMessageBox::critical(d->m_mainWindow, tr("File Error"), errorString); + QMessageBox::critical(d->m_mainWindow, tr("File Error"), + tr("Error while saving file: %1").arg(errorString)); out: ret = false; } @@ -992,7 +993,10 @@ void DocumentManager::checkForReload() // check if IDocument wants us to ask if (document->reloadBehavior(trigger, type) == IDocument::BehaviorSilent) { // content change or removed, IDocument wants silent handling - success = document->reload(&errorString, IDocument::FlagReload, type); + if (type == IDocument::TypeRemoved) + editorsToClose << EditorManager::instance()->editorsForDocument(document); + else + success = document->reload(&errorString, IDocument::FlagReload, type); // IDocument wants us to ask } else if (type == IDocument::TypeContents) { // content change, IDocument wants to ask user diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp index 46caff8e6f9..c332af750f2 100644 --- a/src/plugins/imageviewer/imageviewerfile.cpp +++ b/src/plugins/imageviewer/imageviewerfile.cpp @@ -65,6 +65,15 @@ ImageViewerFile::~ImageViewerFile() delete d; } +Core::IDocument::ReloadBehavior ImageViewerFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +{ + if (type == TypeRemoved || type == TypePermissions) + return BehaviorSilent; + if (type == TypeContents && state == TriggerInternal && !isModified()) + return BehaviorSilent; + return BehaviorAsk; +} + bool ImageViewerFile::reload(QString *errorString, Core::IDocument::ReloadFlag flag, Core::IDocument::ChangeType type) diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h index 2aa820b6fea..ffbb5d64dc8 100644 --- a/src/plugins/imageviewer/imageviewerfile.h +++ b/src/plugins/imageviewer/imageviewerfile.h @@ -61,6 +61,7 @@ public: bool isModified() const; bool isSaveAsAllowed() const; + virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); void setMimetype(const QString &mimetype);