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

List:       kde-bugs-dist
Subject:    [Bug 104129] kate enters an endless loop if a file is changed by
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2005-10-03 9:54:01
Message-ID: 20051003095401.17711.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=104129         
cullmann kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From cullmann kde org  2005-10-03 11:53 -------
SVN commit 466711 by cullmann:

ha, got it ;)
simple race, if not all stuff is selected at all, never all stuff get's cleared, never the while
loop exits, now sane fix: loop once over the list, collect all items we can remove, remove them 
in a extra loop
if some files couldn't be saved or weren't selected, the dialog will stay up with exactly them remaining

BUG: 104129


 M  +15 -8     katemwmodonhddialog.cpp  


--- branches/KDE/3.5/kdebase/kate/app/katemwmodonhddialog.cpp #466710:466711
 @ -138,16 +138,19  @
 
 void KateMwModOnHdDialog::handleSelected( int action )
 {
-  QListViewItemIterator it ( lvDocuments );
-  while ( it.current() )
+  // collect all items we can remove
+  QValueList<QListViewItem *> itemsToDelete;
+  for ( QListViewItemIterator it ( lvDocuments );  it.current(); ++it )
   {
-    KateDocItem *item = (KateDocItem*)it.current();
+    KateDocItem *item = static_cast<KateDocItem *>(it.current());
+    
     if ( item->isOn() )
     {
       int reason = (int)KateDocManager::self()->documentInfo( item->document )->modifiedOnDiscReason;
       bool succes = true;
+      
       Kate::DocumentExt *dext = documentExt( item->document );
-      if ( ! dext ) return;
+      if ( ! dext ) continue;
 
       dext->setModifiedOnDisk( 0 );
       switch ( action )
 @ -161,23 +164,27  @
                                     arg( item->document->url().prettyURL() ) );
           }
           break;
+
         case Reload:
           item->document->reloadFile();
           break;
+
         default:
           break;
       }
 
       if ( succes )
-      {
-        lvDocuments->takeItem( item );
-        delete item;
-      }
+        itemsToDelete.append (item);
       else
         dext->setModifiedOnDisk( reason );
     }
   }
 
+  // remove the marked items
+  for (unsigned int i=0; i < itemsToDelete.count(); ++i)
+    delete itemsToDelete[i];
+
+  // any documents left unhandled?
   if ( ! lvDocuments->childCount() )
     done( Ok );
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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