AutoTest: Clear cached information before running

We cache the last processed model index as well as the used
font. In some cases the cached information interfered with
new information and ended up in an ugly painting issue
where old information partially got repainted instead of
using the new. Clear cached information when starting a new
run to avoid this.

Change-Id: Ibb01e5e3bdd7b542325b5867d37c677d31a14aae
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-10-12 14:56:21 +02:00
parent 72c167be8b
commit 96da2973c3
3 changed files with 9 additions and 0 deletions

View File

@@ -181,6 +181,12 @@ void TestResultDelegate::currentChanged(const QModelIndex &current, const QModel
emit sizeHintChanged(previous); emit sizeHintChanged(previous);
} }
void TestResultDelegate::clearCache()
{
m_lastProcessedIndex = QModelIndex();
m_lastProcessedFont = QFont();
}
void TestResultDelegate::recalculateTextLayout(const QModelIndex &index, const QString &output, void TestResultDelegate::recalculateTextLayout(const QModelIndex &index, const QString &output,
const QFont &font, int width) const const QFont &font, int width) const
{ {

View File

@@ -42,6 +42,7 @@ public:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void currentChanged(const QModelIndex &current, const QModelIndex &previous); void currentChanged(const QModelIndex &current, const QModelIndex &previous);
void clearCache();
private: private:
void recalculateTextLayout(const QModelIndex &index, const QString &output, void recalculateTextLayout(const QModelIndex &index, const QString &output,

View File

@@ -275,6 +275,8 @@ int TestResultsPane::priorityInStatusBar() const
void TestResultsPane::clearContents() void TestResultsPane::clearContents()
{ {
m_filterModel->clearTestResults(); m_filterModel->clearTestResults();
if (auto delegate = qobject_cast<TestResultDelegate *>(m_treeView->itemDelegate()))
delegate->clearCache();
setIconBadgeNumber(0); setIconBadgeNumber(0);
navigateStateChanged(); navigateStateChanged();
m_summaryWidget->setVisible(false); m_summaryWidget->setVisible(false);