$NetBSD: patch-aa,v 1.4 2002/10/26 14:31:13 drochner Exp $ --- kspread/kspread_cell.cc.orig Wed Sep 4 23:52:50 2002 +++ kspread/kspread_cell.cc Fri Oct 25 19:12:19 2002 @@ -1931,20 +1931,40 @@ while already drawing the obscuring cell -- don't want to cause an infinite loop */ - // Determine the dimension of the cell. + + /* + Store the obscuringCells list in a list of QPoint(column, row) + This avoids crashes during the iteration through obscuringCells, + when the cells may get non valid or the list itself gets changed + during a call of obscuringCell->paintCell (this happens e.g. when + there is an updateDepend) + */ + QValueList listPoints; QValueList::iterator it = m_ObscuringCells.begin(); QValueList::iterator end = m_ObscuringCells.end(); - for ( ; it != end; ++it ) { + for ( ; it != end; ++it ) + { KSpreadCell *obscuringCell = *it; - QPoint obscuringCellRef( obscuringCell->column(), obscuringCell->row() ); - double x = m_pTable->dblColumnPos( obscuringCell->column() ); - double y = m_pTable->dblRowPos( obscuringCell->row() ); - QPair corner = qMakePair( x, y ); - painter.save(); + listPoints.append( QPoint( obscuringCell->column(), obscuringCell->row() ) ); + } + + QValueList::iterator it1 = listPoints.begin(); + QValueList::iterator end1 = listPoints.end(); + for ( ; it1 != end1; ++it1 ) + { + QPoint obscuringCellRef = *it1; + KSpreadCell *obscuringCell = m_pTable->cellAt( obscuringCellRef.x(), obscuringCellRef.y() ); + if( obscuringCell != 0 ) + { + double x = m_pTable->dblColumnPos( obscuringCellRef.x() ); + double y = m_pTable->dblRowPos( obscuringCellRef.y() ); + QPair corner = qMakePair( x, y ); + painter.save(); - obscuringCell->paintCell( rect, painter, view, - corner, obscuringCellRef ); - painter.restore(); + obscuringCell->paintCell( rect, painter, view, + corner, obscuringCellRef ); + painter.restore(); + } } } }