Patch to fix 139120 in AM

Andreas Pakulat apaku at gmx.de
Sun Jan 14 23:21:36 UTC 2007


Hi,

the attached patch fixes the crash reported in 139120. The problem seems
to be that there are listviewitems created upon class creation (or maybe
already when creating a subproject), but those are then taken out from
the lower listview again. Later on when changing the selection to
another subproject the slot iterates over all existing targets, instead
of only over the ones that actually are in the listview. The patch
changes this to only iterate over the top-level listviewitems. The same
method works in the QM since "ever" (it was used before I took it over),
so it should be safe. Nevertheless I'm posting here as it might have
side-effects I'm not aware of.

As this should go in before 3.4.0, as soon as more than just me an
teatime agree to apply it please somebody do the commit and close the
bugreport along the way.

Andreas

-- 
You prefer the company of the opposite sex, but are well liked by your own.
-------------- next part --------------
Index: autoprojectwidget.cpp
===================================================================
--- autoprojectwidget.cpp	(Revision 623421)
+++ autoprojectwidget.cpp	(Arbeitskopie)
@@ -512,21 +512,12 @@ void AutoProjectWidget::slotOverviewSele
 		// Remove all TargetItems and all of their children from the view
 		kdDebug ( 9020 ) << "m_shownSubproject (before takeItem()): " << m_shownSubproject->subdir << endl;
 
-		QPtrListIterator<TargetItem> it1( m_shownSubproject->targets );
-		for ( ; it1.current(); ++it1 )
+		QListViewItem* i = m_detailView->listView()->firstChild();
+		while( i )
 		{
-			// After AddTargetDialog, it can happen that an
-			// item is not yet in the list view, so better check...
-			kdDebug ( 9020 ) << "take child items of  " << ( *it1 )->name << endl;
-			if ( it1.current() ->parent() )
-			{
-				while ( ( *it1 ) ->firstChild() )
-				{
-					kdDebug ( 9020 ) << "take FileItem " << ( *it1 ) ->firstChild()->text(0) << endl;
-					( *it1 ) ->takeItem( ( *it1 ) ->firstChild() );
-				}
-			}
-			m_detailView->listView()->takeItem( *it1 );
+			QListViewItem* o = i;
+			i = i->nextSibling();
+			m_detailView->listView()->takeItem(o);
 		}
 	}
 


More information about the KDevelop-devel mailing list