]> cloud.milkyroute.net Git - dolphin.git/commitdiff
It is a valid use-case that m_itemView is 0.
authorPeter Penz <peter.penz19@gmail.com>
Fri, 15 Oct 2010 11:44:43 +0000 (11:44 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 15 Oct 2010 11:44:43 +0000 (11:44 +0000)
BUG: 254240

svn path=/trunk/KDE/kdebase/apps/; revision=1186206

src/views/dolphinviewcontroller.cpp

index f82b6755a5d7aea1ceee607306d46b4a337aa7bf..6e2570007e5ec065a81fd4a7d64f124b50f0492e 100644 (file)
@@ -128,7 +128,9 @@ QList<QAction*> DolphinViewController::versionControlActions(const KFileItemList
 
 void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
 {
-    Q_ASSERT(m_itemView != 0);
+    if (m_itemView == 0) {
+        return;
+    }
 
     const QItemSelectionModel* selModel = m_itemView->selectionModel();
     const QModelIndex currentIndex = selModel->currentIndex();
@@ -194,13 +196,13 @@ void DolphinViewController::emitItemTriggered(const KFileItem& item)
 
 KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const
 {
-    Q_ASSERT(m_itemView != 0);
-
-    QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
-    if (proxyModel != 0) {
-        KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
-        const QModelIndex dirIndex = proxyModel->mapToSource(index);
-        return dirModel->itemForIndex(dirIndex);
+    if (m_itemView != 0) {
+        QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
+        if (proxyModel != 0) {
+            KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+            const QModelIndex dirIndex = proxyModel->mapToSource(index);
+            return dirModel->itemForIndex(dirIndex);
+        }
     }
 
     return KFileItem();
@@ -212,7 +214,7 @@ void DolphinViewController::triggerItem(const QModelIndex& index)
         const KFileItem item = itemForIndex(index);
         if (index.isValid() && (index.column() == KDirModel::Name)) {
             emit itemTriggered(item);
-        } else {
+        } else if (m_itemView != 0) {
             m_itemView->clearSelection();
             emit itemEntered(KFileItem());
         }