From f4f06d48d852437ee0d70b7541c9b8a1893d9624 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Jan 2013 00:01:24 +0100 Subject: [PATCH] fix for gcc. simplify mainwin.cc a bit. --- src/highlighter.cc | 4 +++- src/highlighter.h | 4 ++-- src/mainwin.cc | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/highlighter.cc b/src/highlighter.cc index ab0a071a..98eff8c6 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -160,6 +160,8 @@ Highlighter::Highlighter(QTextDocument *parent) commentFormat.setForeground(Qt::darkCyan); errorFormat.setBackground(Qt::red); + errorState = false; + errorPos = -1; lastErrorBlock = parent->begin(); } @@ -209,7 +211,7 @@ void Highlighter::portable_rehighlightBlock( const QTextBlock &block ) void Highlighter::highlightBlock(const QString &text) { int block_first_pos = currentBlock().position(); - int block_last_pos = block_first_pos + currentBlock().length() - 1; + //int block_last_pos = block_first_pos + currentBlock().length() - 1; //std::cout << "block[" << block_first_pos << ":" << block_last_pos << "]" // << ", err:" << errorPos << "," << errorState // << ", text:'" << text.toStdString() << "'\n"; diff --git a/src/highlighter.h b/src/highlighter.h index 322ba2d4..09bba392 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -15,8 +15,8 @@ public: void unhighlightLastError(); private: QTextBlock lastErrorBlock; - int errorPos = -1; - bool errorState = false; + int errorPos; + bool errorState; QMap tokentypes; QMap typeformats; void portable_rehighlightBlock( const QTextBlock &text ); diff --git a/src/mainwin.cc b/src/mainwin.cc index 8834b75d..6bb43e68 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1037,14 +1037,12 @@ bool MainWindow::compileTopLevelDocument(bool reload) false); if (!animate_panel->isVisible()) { + highlighter->unhighlightLastError(); if (!this->root_module) { - highlighter->unhighlightLastError(); QTextCursor cursor = editor->textCursor(); - cursor.setPosition( parser_error_pos ); - editor->setTextCursor( cursor ); + cursor.setPosition(parser_error_pos); + editor->setTextCursor(cursor); highlighter->highlightError( parser_error_pos ); - } else { - highlighter->unhighlightLastError(); } }