TextEditors: Fix wrong revision marker after undo/redo

The block revisions where no longer reset when the editor goes back to
unmodified state (when doing undo or redo), which broke in the recent
refactoring.

Task-number: QTCREATORBUG-11402
Change-Id: I2de24fcc42568f3f7e48a94d391bb9b83c8c4280
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Eike Ziller
2014-02-11 11:54:36 +01:00
parent 45b7451a88
commit 643fcd36cb

View File

@@ -64,8 +64,9 @@ using namespace Core;
*/
namespace TextEditor {
class BaseTextDocumentPrivate
class BaseTextDocumentPrivate : public QObject
{
Q_OBJECT
public:
explicit BaseTextDocumentPrivate(BaseTextDocument *q);
@@ -73,6 +74,10 @@ public:
void resetRevisions();
void updateRevisions();
public slots:
void onModificationChanged(bool modified);
public:
QString m_defaultPath;
QString m_suggestedFileName;
QString m_mimeType;
@@ -179,8 +184,17 @@ void BaseTextDocumentPrivate::updateRevisions()
}
}
void BaseTextDocumentPrivate::onModificationChanged(bool modified)
{
// we only want to update the block revisions when going back to the saved version,
// e.g. with undo
if (!modified)
updateRevisions();
}
BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
{
connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool)));
connect(d->m_document, SIGNAL(modificationChanged(bool)), this, SIGNAL(changed()));
connect(d->m_document, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
@@ -468,8 +482,7 @@ bool BaseTextDocument::save(QString *errorString, const QString &saveFileName, b
// inform about the new filename
const QFileInfo fi(fName);
d->updateRevisions();
d->m_document->setModified(false);
d->m_document->setModified(false); // also triggers update of the block revisions
setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
emit changed();
return true;
@@ -686,3 +699,5 @@ void BaseTextDocument::ensureFinalNewLine(QTextCursor& cursor)
}
} // namespace TextEditor
#include "basetextdocument.moc"