[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    KSpread: Patch for crash with merged cells
From:       Philipp =?iso-8859-15?q?M=FCller?= <philipp.mueller () gmx ! de>
Date:       2002-10-21 18:52:05
[Download RAW message or body]

Dear KSpread users,

please find attached a patch for KSpread, which should solve all the crashes 
which can occur when the sheet contains merged cells or a cell with long 
text, which overlapps the next cell(s).

Crashes occured also while loading documents saved with KSpread 1.1 
(containing merged/overlapping cells).

I'm sending this patch to the list for all users with problems due to this 
crash, who cannot wait for the next bug fix release KOffice 1.2.1.

Best regards,

Philipp



["kspread_obscured_cells.patch" (text/x-diff)]

Index: kspread_cell.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_cell.cc,v
retrieving revision 1.447.2.1
diff -u -r1.447.2.1 kspread_cell.cc
--- kspread_cell.cc	2002/09/04 06:59:13	1.447.2.1
+++ kspread_cell.cc	2002/10/21 18:31:51
@@ -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<QPoint> listPoints;
     QValueList<KSpreadCell*>::iterator it = m_ObscuringCells.begin();
     QValueList<KSpreadCell*>::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<double,double> corner = qMakePair( x, y );
-      painter.save();
+      listPoints.append( QPoint( obscuringCell->column(), obscuringCell->row() ) );
+    }
+
+    QValueList<QPoint>::iterator it1 = listPoints.begin();
+    QValueList<QPoint>::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<double,double> corner = qMakePair( x, y );
+        painter.save();
 
-      obscuringCell->paintCell( rect, painter, view,
-                                corner, obscuringCellRef );
-      painter.restore();
+        obscuringCell->paintCell( rect, painter, view,
+                                  corner, obscuringCellRef );
+        painter.restore();
+      }
     }
   }
 }

____________________________________
koffice mailing list
koffice@mail.kde.org
To unsubscribe please visit:
http://mail.kde.org/mailman/listinfo/koffice

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic