forked from qt-creator/qt-creator
Fix reloading behavior of image viewer.
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 <robert.loehning@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -667,7 +667,8 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName,
|
|||||||
}
|
}
|
||||||
*isReadOnly = false;
|
*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:
|
out:
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@@ -992,7 +993,10 @@ void DocumentManager::checkForReload()
|
|||||||
// check if IDocument wants us to ask
|
// check if IDocument wants us to ask
|
||||||
if (document->reloadBehavior(trigger, type) == IDocument::BehaviorSilent) {
|
if (document->reloadBehavior(trigger, type) == IDocument::BehaviorSilent) {
|
||||||
// content change or removed, IDocument wants silent handling
|
// 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
|
// IDocument wants us to ask
|
||||||
} else if (type == IDocument::TypeContents) {
|
} else if (type == IDocument::TypeContents) {
|
||||||
// content change, IDocument wants to ask user
|
// content change, IDocument wants to ask user
|
||||||
|
@@ -65,6 +65,15 @@ ImageViewerFile::~ImageViewerFile()
|
|||||||
delete d;
|
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,
|
bool ImageViewerFile::reload(QString *errorString,
|
||||||
Core::IDocument::ReloadFlag flag,
|
Core::IDocument::ReloadFlag flag,
|
||||||
Core::IDocument::ChangeType type)
|
Core::IDocument::ChangeType type)
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
bool isModified() const;
|
bool isModified() const;
|
||||||
bool isSaveAsAllowed() const;
|
bool isSaveAsAllowed() const;
|
||||||
|
|
||||||
|
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
||||||
|
|
||||||
void setMimetype(const QString &mimetype);
|
void setMimetype(const QString &mimetype);
|
||||||
|
Reference in New Issue
Block a user