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

List:       kde-commits
Subject:    [kdiagram] src/KGantt: Avoid crash if leftView() is not a KGanttTreeView
From:       Dag Andersen <null () kde ! org>
Date:       2017-12-14 9:14:53
Message-ID: E1ePPbR-00039P-C4 () code ! kde ! org
[Download RAW message or body]

Git commit 3dd287a4412ddf2704077df98a711763379f0e60 by Dag Andersen.
Committed on 14/12/2017 at 09:14.
Pushed by danders into branch 'master'.

Avoid crash if leftView() is not a KGanttTreeView

Todo: implement expandAll/collapseAll to work with any QAbstractItemView

CCMAIL:kossebau@kde.org

M  +12   -2    src/KGantt/kganttview.cpp

https://commits.kde.org/kdiagram/3dd287a4412ddf2704077df98a711763379f0e60

diff --git a/src/KGantt/kganttview.cpp b/src/KGantt/kganttview.cpp
index 2735986..a1b1664 100644
--- a/src/KGantt/kganttview.cpp
+++ b/src/KGantt/kganttview.cpp
@@ -439,14 +439,24 @@ void View::setGrid( AbstractGrid* grid )
 
 void View::expandAll( QModelIndex index )
 {
+    // FIXME:
+    // It is legal to call setLeftView() with any QAbstractItemView,
+    // so expandAll should be reimplemented to work with that.
     KGanttTreeView* tw = qobject_cast<KGanttTreeView*>(leftView());
-    tw->expandAll(index);
+    if (tw) {
+        tw->expandAll(index);
+    }
 }
 
 void View::collapseAll( QModelIndex index )
 {
+    // FIXME:
+    // It is legal to call setLeftView() with any QAbstractItemView,
+    // so expandAll should be reimplemented to work with that.
     KGanttTreeView* tw = qobject_cast<KGanttTreeView*>(leftView());
-    tw->collapseAll(index);
+    if (tw) {
+        tw->collapseAll(index);
+    }
 }
 
 /*! \returns the AbstractGrid used by this view.
[prev in list] [next in list] [prev in thread] [next in thread] 

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