From df45f800e1f245682e374a07bc3ba2a39816256f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 26 Nov 2018 14:29:37 +0100 Subject: [PATCH] [escher] SelectableTableView: fix wrong assert --- escher/src/selectable_table_view.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index 634ea08d5..05c003d3b 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -158,7 +158,15 @@ void SelectableTableView::unhighlightSelectedCell() { if (selectedColumn() >= 0 && selectedColumn() < dataSource()->numberOfColumns() && selectedRow() >= 0 && selectedRow() < dataSource()->numberOfRows()) { HighlightCell * previousCell = cellAtLocation(selectedColumn(), selectedRow()); - assert(previousCell); - previousCell->setHighlighted(false); + /* Previous cell does not always exist. + * For example, unhighlightSelectedCell can be called twice: + * - from selectCellAtLocation + * - and then from m_delegate->tableViewDidChangeSelection inside unhighlightSelectedCell + * The first call selects an invisible cell. At the time of the second call, + * the selected cell might be still invisible because scrolling happens + * after. */ + if (previousCell) { + previousCell->setHighlighted(false); + } } }