summaryrefslogtreecommitdiff
path: root/src/plugins/autotest
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-01 15:50:34 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-10 05:06:47 +0000
commitcd1a848e16c400d5d32bda2fb1eaf0f99e25f9da (patch)
tree287326cc556b84790d411ab02a61436544c80752 /src/plugins/autotest
parent3db5f4a2afec36a8168878691e50ad6c5bdbad6c (diff)
downloadqt-creator-cd1a848e16c400d5d32bda2fb1eaf0f99e25f9da.tar.gz
AutoTest: Fix wrong caching of text layout
The text layout must get recalculated also when the width of the underlying model index has changed. Fixes: QTCREATORBUG-24236 Change-Id: I4ded56832c765320b6845cf35ad61453875dad50 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r--src/plugins/autotest/testresultdelegate.cpp4
-rw-r--r--src/plugins/autotest/testresultdelegate.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/autotest/testresultdelegate.cpp b/src/plugins/autotest/testresultdelegate.cpp
index f5486149af..09c44083e8 100644
--- a/src/plugins/autotest/testresultdelegate.cpp
+++ b/src/plugins/autotest/testresultdelegate.cpp
@@ -186,18 +186,20 @@ void TestResultDelegate::clearCache()
{
m_lastProcessedIndex = QModelIndex();
m_lastProcessedFont = QFont();
+ m_lastWidth = -1;
}
void TestResultDelegate::recalculateTextLayout(const QModelIndex &index, const QString &output,
const QFont &font, int width) const
{
- if (m_lastProcessedIndex == index && m_lastProcessedFont == font)
+ if (m_lastWidth == width && m_lastProcessedIndex == index && m_lastProcessedFont == font)
return;
const QFontMetrics fm(font);
const int leading = fm.leading();
const int fontHeight = fm.height();
+ m_lastWidth = width;
m_lastProcessedIndex = index;
m_lastProcessedFont = font;
m_lastCalculatedHeight = 0;
diff --git a/src/plugins/autotest/testresultdelegate.h b/src/plugins/autotest/testresultdelegate.h
index 73b2d8291b..ce54ddf567 100644
--- a/src/plugins/autotest/testresultdelegate.h
+++ b/src/plugins/autotest/testresultdelegate.h
@@ -52,6 +52,7 @@ private:
mutable QFont m_lastProcessedFont;
mutable QTextLayout m_lastCalculatedLayout;
mutable int m_lastCalculatedHeight;
+ mutable int m_lastWidth = -1;
class LayoutPositions
{