summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-03-01 13:43:24 (GMT)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-03-02 09:59:10 (GMT)
commit340eb4f20a5976be77ee66bbfc2ef16c97b033d2 (patch)
tree79581fcd0a0eb3b8e46ca26714421da93b3628d5 /src/gui/text
parent6cacc89eeac80084112c37e3cbcfcd8325192b8f (diff)
downloadQt-340eb4f20a5976be77ee66bbfc2ef16c97b033d2.zip
Qt-340eb4f20a5976be77ee66bbfc2ef16c97b033d2.tar.gz
Qt-340eb4f20a5976be77ee66bbfc2ef16c97b033d2.tar.bz2
replace temporary disconnection with a very simple statemachine
this also fixes an issue with non-constant ordering of connections to document's contentsChange() signal Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 6750c09..9b3671d 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -59,23 +59,24 @@ class QSyntaxHighlighterPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QSyntaxHighlighter)
public:
- inline QSyntaxHighlighterPrivate() : rehighlightPending(false) {}
+ inline QSyntaxHighlighterPrivate()
+ : rehighlightPending(false), inReformatBlocks(false)
+ {}
QPointer<QTextDocument> doc;
void _q_reformatBlocks(int from, int charsRemoved, int charsAdded);
+ void reformatBlocks(int from, int charsRemoved, int charsAdded);
void reformatBlock(QTextBlock block);
inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
- QObject::disconnect(doc, SIGNAL(contentsChange(int,int,int)),
- q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ inReformatBlocks = true;
cursor.beginEditBlock();
int from = cursor.position();
cursor.movePosition(operation);
- _q_reformatBlocks(from, 0, cursor.position() - from);
+ reformatBlocks(from, 0, cursor.position() - from);
cursor.endEditBlock();
- QObject::connect(doc, SIGNAL(contentsChange(int,int,int)),
- q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ inReformatBlocks = false;
}
inline void _q_delayedRehighlight() {
@@ -90,6 +91,7 @@ public:
QVector<QTextCharFormat> formatChanges;
QTextBlock currentBlock;
bool rehighlightPending;
+ bool inReformatBlocks;
};
void QSyntaxHighlighterPrivate::applyFormatChanges()
@@ -162,6 +164,12 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded)
{
+ if (!inReformatBlocks)
+ reformatBlocks(from, charsRemoved, charsAdded);
+}
+
+void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded)
+{
Q_UNUSED(charsRemoved);
rehighlightPending = false;