forked from qt-creator/qt-creator
DiffEditor: disable saveAs action during reload
Change-Id: I6786139c1cd9c9e3c0786b14da058cb260fba3ed Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -203,11 +203,19 @@ QString DiffEditorDocument::fallbackSaveAsPath() const
|
|||||||
return QDir::homePath();
|
return QDir::homePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DiffEditorDocument::isSaveAsAllowed() const
|
||||||
|
{
|
||||||
|
return !isReloading();
|
||||||
|
}
|
||||||
|
|
||||||
bool DiffEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool DiffEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
Q_UNUSED(autoSave)
|
Q_UNUSED(autoSave)
|
||||||
|
|
||||||
|
if (isReloading())
|
||||||
|
return false;
|
||||||
|
|
||||||
const bool ok = write(fileName, format(), plainText(), errorString);
|
const bool ok = write(fileName, format(), plainText(), errorString);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
@@ -330,6 +338,7 @@ void DiffEditorDocument::beginReload()
|
|||||||
{
|
{
|
||||||
emit aboutToReload();
|
emit aboutToReload();
|
||||||
m_isReloading = true;
|
m_isReloading = true;
|
||||||
|
emit changed();
|
||||||
const bool blocked = blockSignals(true);
|
const bool blocked = blockSignals(true);
|
||||||
setDiffFiles(QList<FileData>(), QString());
|
setDiffFiles(QList<FileData>(), QString());
|
||||||
setDescription(QString());
|
setDescription(QString());
|
||||||
@@ -339,6 +348,7 @@ void DiffEditorDocument::beginReload()
|
|||||||
void DiffEditorDocument::endReload(bool success)
|
void DiffEditorDocument::endReload(bool success)
|
||||||
{
|
{
|
||||||
m_isReloading = false;
|
m_isReloading = false;
|
||||||
|
emit changed();
|
||||||
emit reloadFinished(success);
|
emit reloadFinished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
QString fallbackSaveAsPath() const override;
|
QString fallbackSaveAsPath() const override;
|
||||||
QString fallbackSaveAsFileName() const override;
|
QString fallbackSaveAsFileName() const override;
|
||||||
|
|
||||||
bool isSaveAsAllowed() const override { return true; }
|
bool isSaveAsAllowed() const override;
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
||||||
void reload();
|
void reload();
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
|
Reference in New Issue
Block a user