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

List:       kde-commits
Subject:    KDE/kdepim/kdgantt
From:       Dag Andersen <danders () get2net ! dk>
Date:       2008-03-24 15:58:29
Message-ID: 1206374309.218279.26319.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 789559 by danders:

Fix crash when collapsing items with constraints (dependencies).


 M  +18 -12    kdganttgraphicsscene.cpp  


--- trunk/KDE/kdepim/kdgantt/kdganttgraphicsscene.cpp #789558:789559
@@ -412,30 +412,36 @@
     //qDebug() << "GraphicsScene::removeItem("<<idx<<")";
     QHash<QPersistentModelIndex,GraphicsItem*>::iterator it = d->items.find( idx );
     if ( it != d->items.end() ) {
+        GraphicsItem* item = *it;
+        // We have to remove the item from the list first because
+        // there is a good chance there will be reentrant calls
+        d->items.erase( it );
         {
             // Remove any constraintitems starting here
-            const QList<ConstraintGraphicsItem*> clst = ( *it )->startConstraints();
-            //qDebug() << clst;
+            const QList<ConstraintGraphicsItem*> clst = item->startConstraints();
+            //qDebug() << "GraphicsScene::removeItem" << clst;
             Q_FOREACH( ConstraintGraphicsItem* citem, clst ) {
-                GraphicsItem* end_item = d->items.value( \
summaryHandlingModel()->mapFromSource( citem->constraint().endIndex() ),0 ); +        \
const Constraint c = citem->constraint(); +                GraphicsItem* end_item = \
d->items.value( summaryHandlingModel()->mapFromSource( c.endIndex() ),0 );  if ( \
                end_item ) end_item->removeEndConstraint( citem );
-                d->constraintModel->removeConstraint( citem->constraint() );
+                //d->constraintModel->removeConstraint( c );
                 delete citem;
             }
         }
-        {// Remove any constraintitems ending here
-            const QList<ConstraintGraphicsItem*> clst = ( *it )->endConstraints();
-            //qDebug() << clst;
+        {
+            const QList<ConstraintGraphicsItem*> clst = item->endConstraints();
+            //qDebug() << "GraphicsScene::removeItem" << clst;
             Q_FOREACH( ConstraintGraphicsItem* citem, clst ) {
-                GraphicsItem* end_item = d->items.value( \
                summaryHandlingModel()->mapFromSource( citem->constraint().endIndex() \
                ),0 );
-                if ( end_item ) end_item->removeStartConstraint( citem );
-                d->constraintModel->removeConstraint( citem->constraint() );
+                const Constraint c = citem->constraint();
+                GraphicsItem* start_item = d->items.value( \
summaryHandlingModel()->mapFromSource( c.startIndex() ),0 ); +                if ( \
start_item ) start_item->removeStartConstraint( citem ); +                \
//d->constraintModel->removeConstraint( c );  delete citem;
             }
+            // Remove any constraintitems ending here
         }
         // Get rid of the item
-        delete *it;
-        d->items.erase( it );
+        delete item;
     }
 }
 


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

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