aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-04 16:51:38 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-07 08:35:15 +0000
commitb0cad9e9c7aad209756fb2409520c0d048614dd9 (patch)
tree1cd9e91cfa0278ce35f3f3d272635d390d866e00
parentf73f11d8c6418141581a77b97fc3c479a1bbaae5 (diff)
OutputFormatter: Fix visual glitchqds/v1.6.0-rc1qds/1.6.0-rc1
When inserting a line into an output window, we have to delay appending the line feed character. Otherwise strange visual effects appear under certain circumstances. I have no idea why. Fixes: QTCREATORBUG-24411 Change-Id: If8842ae4d9db36d514996b1f34dcca0432fafbfc Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/libs/utils/outputformatter.cpp14
-rw-r--r--src/libs/utils/outputformatter.h5
-rw-r--r--src/plugins/projectexplorer/linuxiccparser.cpp2
-rw-r--r--src/plugins/projectexplorer/outputparser_test.cpp5
-rw-r--r--src/plugins/qtsupport/qtoutputformatter.cpp1
5 files changed, 20 insertions, 7 deletions
diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp
index 34c76d3ce6..49cb31d3e5 100644
--- a/src/libs/utils/outputformatter.cpp
+++ b/src/libs/utils/outputformatter.cpp
@@ -216,6 +216,7 @@ public:
PostPrintAction postPrintAction;
bool boldFontEnabled = true;
bool prependCarriageReturn = false;
+ bool prependLineFeed = false;
};
OutputFormatter::OutputFormatter() : d(new Private) { }
@@ -436,6 +437,7 @@ void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
startPos = crPos + 1;
}
+ flushTrailingNewline();
if (startPos < text.count())
d->cursor.insertText(text.mid(startPos), format);
}
@@ -495,6 +497,14 @@ void OutputFormatter::flushIncompleteLine()
d->incompleteLine.first.clear();
}
+void Utils::OutputFormatter::flushTrailingNewline()
+{
+ if (d->prependLineFeed) {
+ d->cursor.insertText("\n");
+ d->prependLineFeed = false;
+ }
+}
+
void OutputFormatter::dumpIncompleteLine(const QString &line, OutputFormat format)
{
if (line.isEmpty())
@@ -560,6 +570,7 @@ void OutputFormatter::flush()
{
if (!d->incompleteLine.first.isEmpty())
flushIncompleteLine();
+ flushTrailingNewline();
d->escapeCodeHandler.endFormatScope();
for (OutputLineParser * const p : qAsConst(d->lineParsers))
p->flush();
@@ -641,7 +652,8 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
dumpIncompleteLine(out.mid(startPos), format);
break;
}
- doAppendMessage(out.mid(startPos, eolPos - startPos + 1), format);
+ doAppendMessage(out.mid(startPos, eolPos - startPos), format);
+ d->prependLineFeed = true;
startPos = eolPos + 1;
}
}
diff --git a/src/libs/utils/outputformatter.h b/src/libs/utils/outputformatter.h
index 6c8539d3ed..f9bcb145c3 100644
--- a/src/libs/utils/outputformatter.h
+++ b/src/libs/utils/outputformatter.h
@@ -83,8 +83,8 @@ public:
void setDemoteErrorsToWarnings(bool demote);
bool demoteErrorsToWarnings() const;
- // line contains at most one line feed character, and if it does occur, it's the last character.
- // Either way, the input is to be considered "complete" for parsing purposes.
+ // Represents a single line, without a trailing line feed character.
+ // The input is to be considered "complete" for parsing purposes.
virtual Result handleLine(const QString &line, OutputFormat format) = 0;
virtual bool handleLink(const QString &href) { Q_UNUSED(href); return false; }
@@ -183,6 +183,7 @@ private:
void append(const QString &text, const QTextCharFormat &format);
void initFormats();
void flushIncompleteLine();
+ void flushTrailingNewline();
void dumpIncompleteLine(const QString &line, OutputFormat format);
void clearLastLine();
QList<FormattedText> parseAnsi(const QString &text, const QTextCharFormat &format);
diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp
index 82799fecd6..41d46a3522 100644
--- a/src/plugins/projectexplorer/linuxiccparser.cpp
+++ b/src/plugins/projectexplorer/linuxiccparser.cpp
@@ -57,7 +57,7 @@ LinuxIccParser::LinuxIccParser() :
// ".pch/Qt5Core.pchi.cpp": creating precompiled header file ".pch/Qt5Core.pchi"
// "animation/qabstractanimation.cpp": using precompiled header file ".pch/Qt5Core.pchi"
- m_pchInfoLine.setPattern(QLatin1String("^\".*?\": (creating|using) precompiled header file \".*?\"\n$"));
+ m_pchInfoLine.setPattern(QLatin1String("^\".*?\": (creating|using) precompiled header file \".*?\"$"));
QTC_CHECK(m_pchInfoLine.isValid());
}
diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp
index 99d241bf13..319ae18e44 100644
--- a/src/plugins/projectexplorer/outputparser_test.cpp
+++ b/src/plugins/projectexplorer/outputparser_test.cpp
@@ -111,11 +111,10 @@ TestTerminator::TestTerminator(OutputParserTester *t) :
Utils::OutputLineParser::Result TestTerminator::handleLine(const QString &line, Utils::OutputFormat type)
{
- QTC_CHECK(line.endsWith('\n'));
if (type == Utils::StdOutFormat)
- m_tester->m_receivedStdOutChildLine.append(line);
+ m_tester->m_receivedStdOutChildLine.append(line + '\n');
else
- m_tester->m_receivedStdErrChildLine.append(line);
+ m_tester->m_receivedStdErrChildLine.append(line + '\n');
return Status::Done;
}
diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp
index 8975328dd0..01036dbaaa 100644
--- a/src/plugins/qtsupport/qtoutputformatter.cpp
+++ b/src/plugins/qtsupport/qtoutputformatter.cpp
@@ -511,6 +511,7 @@ void QtSupportPlugin::testQtOutputFormatter_appendMixedAssertAndAnsi()
"Blue\n";
formatter.appendMessage(inputText, StdOutFormat);
+ formatter.flush();
QCOMPARE(edit.toPlainText(), outputText);