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

List:       kde-commits
Subject:    [kdepim/KDE/4.8] kmail: in updateShortcutsForIndex(), check that the model does indeed have
From:       Allen Winter <winter () kde ! org>
Date:       2012-01-19 23:44:02
Message-ID: 20120119234402.A712AA60A6 () git ! kde ! org
[Download RAW message or body]

Git commit f4fa3aebfa15c80abedbc82090e7c2f8ad5d20dc by Allen Winter.
Committed on 20/01/2012 at 00:37.
Pushed by winterz into branch 'KDE/4.8'.

in updateShortcutsForIndex(), check that the model does indeed have
a valid index for the specified row indexes before accessing them.
probably fixes the crash mentioned in 291886.

BUG: 291886
FIXED-IN: 4.8.1
MERGE: 4.8
(cherry picked from commit 3b492be3ef3404cac5c91b23a0cce7a9334a5dc5)

M  +13   -9    kmail/foldershortcutactionmanager.cpp

http://commits.kde.org/kdepim/f4fa3aebfa15c80abedbc82090e7c2f8ad5d20dc

diff --git a/kmail/foldershortcutactionmanager.cpp \
b/kmail/foldershortcutactionmanager.cpp index ed581db..e753a04 100644
--- a/kmail/foldershortcutactionmanager.cpp
+++ b/kmail/foldershortcutactionmanager.cpp
@@ -80,8 +80,9 @@ void FolderShortcutActionManager::createActions()
   connect( KernelIf->folderCollectionMonitor(), \
                SIGNAL(collectionRemoved(Akonadi::Collection)),
            this, SLOT(slotCollectionRemoved(Akonadi::Collection)), \
Qt::UniqueConnection );  
-  if ( model->rowCount() > 0 )
+  if ( model->rowCount() > 0 ) {
     updateShortcutsForIndex( QModelIndex(), 0, model->rowCount() - 1 );
+  }
 }
 
 void FolderShortcutActionManager::slotRowsInserted( const QModelIndex &parent, int \
start, int end ) @@ -89,18 +90,21 @@ void \
FolderShortcutActionManager::slotRowsInserted( const QModelIndex &parent, i  \
updateShortcutsForIndex( parent, start, end );  }
 
-void FolderShortcutActionManager::updateShortcutsForIndex( const QModelIndex \
&parent, int start, int end ) +void \
FolderShortcutActionManager::updateShortcutsForIndex( const QModelIndex &parent, +    \
int start, int end )  {
   QAbstractItemModel *model = KernelIf->collectionModel();
   for ( int i = start; i <= end; i++ ) {
-    const QModelIndex child = model->index( i, 0, parent );
-    Akonadi::Collection collection =
+    if ( model->hasIndex( i, 0, parent ) ) {
+      const QModelIndex child = model->index( i, 0, parent );
+      Akonadi::Collection collection =
         model->data( child, Akonadi::EntityTreeModel::CollectionRole \
                ).value<Akonadi::Collection>();
-    if ( collection.isValid() ) {
-      shortcutChanged( collection );
-    }
-    if ( model->rowCount( child ) > 0 ) {
-      updateShortcutsForIndex( child, 0, model->rowCount( child ) - 1 );
+      if ( collection.isValid() ) {
+        shortcutChanged( collection );
+      }
+      if ( model->rowCount( child ) > 0 ) {
+        updateShortcutsForIndex( child, 0, model->rowCount( child ) - 1 );
+      }
     }
   }
 }


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

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