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

List:       kde-commits
Subject:    playground/office/kraft/src
From:       Klaas Freitag <klaas () freisturz ! de>
Date:       2011-11-02 20:39:40
Message-ID: 20111102203940.939A0AC88A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1262346 by freitag:

fix crash in catalog listview selection

 M  +9 -6      kataloglistview.cpp  
 M  +1 -1      materialkatalogview.cpp  
 M  +4 -1      materialselectdialog.cpp  


--- trunk/playground/office/kraft/src/kataloglistview.cpp #1262345:1262346
@@ -202,7 +202,11 @@
     QTreeWidgetItemIterator it( this, QTreeWidgetItemIterator::Checked );
     while (*it) {
       QTreeWidgetItem *item = *it;
-      templates.append( static_cast<CatalogTemplate*>( itemData( item )));
+      if( ! (isChapter( item ) || isRoot(item )) ) { // a template, not a chapter.
+        void *data = itemData( item );
+        if( data )
+          templates.append( static_cast<CatalogTemplate*>( data ));
+      }
       item->setCheckState( 0, Qt::Unchecked );
       ++it;
     }
@@ -212,12 +216,14 @@
     QList<QTreeWidgetItem*> items = selectedItems();
 
     foreach( QTreeWidgetItem* item, items ) {
+      if( !(isChapter(item) || isRoot(item))) {
       void *data = itemData( item );
-      if( data ) {
+        if( data )
         templates.append( static_cast<CatalogTemplate*>(data) );
       }
     }
   }
+
   return templates;
 }
 
@@ -231,12 +237,8 @@
 
 void* KatalogListView::currentItemData()
 {
-  if( currentItem() ) {
     return itemData( currentItem() );
-  } else {
-    return 0;
   }
-}
 
 void KatalogListView::removeTemplateItem( QTreeWidgetItem *item )
 {
@@ -287,6 +289,7 @@
   QTreeWidgetItem *item = currentItem();
   if( ! isChapter( item )) {
     kDebug() << "Can only edit chapters!" << endl;
+    return;
   }
   CatalogChapter *chap = static_cast<CatalogChapter*>( itemData( item ) );
 
--- trunk/playground/office/kraft/src/materialkatalogview.cpp #1262345:1262346
@@ -108,7 +108,7 @@
     }
   }
 
-  if( parentItem ) {
+  if( parentItem && listview->isChapter( parentItem )) {
     // try to find out which catalog is open/current
     CatalogChapter *chap = static_cast<CatalogChapter*>(listview->itemData( parentItem ));
     newMat->setChapter( chap->id().toInt() );
--- trunk/playground/office/kraft/src/materialselectdialog.cpp #1262345:1262346
@@ -71,10 +71,13 @@
   QTreeWidgetItemIterator it( mKatalogListView, QTreeWidgetItemIterator::Checked	);
   while (*it) {
     kDebug() << "T: " << (*it)->text( 0 ) << endl;
-    StockMaterial *mat = static_cast<StockMaterial*>( mKatalogListView->itemData( *it ) );
+    QTreeWidgetItem *item = *it;
+    if( !( mKatalogListView->isChapter( item ) || mKatalogListView->isRoot( item ))) {
+      StockMaterial *mat = static_cast<StockMaterial*>( mKatalogListView->itemData( item ) );
     if ( mat ) {
       emit materialSelected( mat->getID(), 1 );
     }
+    }
     ++it;
   }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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