]> cloud.milkyroute.net Git - dolphin.git/commitdiff
fix crash for the following use case:
authorPeter Penz <peter.penz19@gmail.com>
Sun, 18 Nov 2007 13:24:43 +0000 (13:24 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 18 Nov 2007 13:24:43 +0000 (13:24 +0000)
- open a view with no selection
- press SHIFT + right mouse-click on an item
- a context menu will be opened although no item has been selected -> assertion gets triggered later

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

src/dolphincolumnwidget.cpp
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp

index 2dc3bc1530bf6f0be7bf12f741f3bc9a7f909a65..7681b88389c583a05a6ddaef62c10cc1cb89790a 100644 (file)
@@ -309,12 +309,14 @@ void DolphinColumnWidget::contextMenuEvent(QContextMenuEvent* event)
 
     QListView::contextMenuEvent(event);
 
 
     QListView::contextMenuEvent(event);
 
-    const QModelIndex index = indexAt(event->pos());
-    if (index.isValid() || m_active) {
-        // Only open a context menu above an item or if the mouse is above
-        // the active column.
-        const QPoint pos = m_view->viewport()->mapFromGlobal(event->globalPos());
-        m_view->m_controller->triggerContextMenuRequest(pos);
+    if (selectionModel()->hasSelection()) {
+        const QModelIndex index = indexAt(event->pos());
+        if (index.isValid() || m_active) {
+            // Only open a context menu above an item or if the mouse is above
+            // the active column.
+            const QPoint pos = m_view->viewport()->mapFromGlobal(event->globalPos());
+            m_view->m_controller->triggerContextMenuRequest(pos);
+        }
     }
 }
 
     }
 }
 
index f4bba2f039c1748a264feae271081d854fcdfd94..9dd91b308c5b0c5b720d1cf07a1f0a591fed1d7b 100644 (file)
@@ -167,7 +167,9 @@ QStyleOptionViewItem DolphinDetailsView::viewOptions() const
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QTreeView::contextMenuEvent(event);
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QTreeView::contextMenuEvent(event);
-    m_controller->triggerContextMenuRequest(event->pos());
+    if (selectionModel()->hasSelection()) {
+        m_controller->triggerContextMenuRequest(event->pos());
+    }
 }
 
 void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
 }
 
 void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
index 08ff9cf48894ecd2c39aea8bd33002c5967084ec..95ea011b03aa83a2514ce3c3f6b069398dba0929 100644 (file)
@@ -162,7 +162,9 @@ QStyleOptionViewItem DolphinIconsView::viewOptions() const
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     KCategorizedView::contextMenuEvent(event);
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     KCategorizedView::contextMenuEvent(event);
-    m_controller->triggerContextMenuRequest(event->pos());
+    if (selectionModel()->hasSelection()) {
+        m_controller->triggerContextMenuRequest(event->pos());
+    }
 }
 
 void DolphinIconsView::mousePressEvent(QMouseEvent* event)
 }
 
 void DolphinIconsView::mousePressEvent(QMouseEvent* event)