summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2014-02-11 11:54:36 +0100
committerEike Ziller <eike.ziller@digia.com>2014-02-13 11:14:52 +0100
commit643fcd36cbd3e8b938d269920757b9952bdea562 (patch)
treebdd38e3273c388e7cbe636ca4b8624eec351f331 /src/plugins
parent45b7451a88a6d6a0bd348747369f312dc5970740 (diff)
downloadqt-creator-643fcd36cbd3e8b938d269920757b9952bdea562.tar.gz
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>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 984d522f34..7c9a30ff68 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -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"