forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
|
@@ -52,6 +52,7 @@ private:
|
||||
mutable QFont m_lastProcessedFont;
|
||||
mutable QTextLayout m_lastCalculatedLayout;
|
||||
mutable int m_lastCalculatedHeight;
|
||||
mutable int m_lastWidth = -1;
|
||||
|
||||
class LayoutPositions
|
||||
{
|
||||
|
Reference in New Issue
Block a user