Explorar o código

GTableView: Double-click should only activate/edit valid indices.

Andreas Kling %!s(int64=6) %!d(string=hai) anos
pai
achega
8a3d00ac02
Modificáronse 1 ficheiros con 7 adicións e 4 borrados
  1. 7 4
      LibGUI/GTableView.cpp

+ 7 - 4
LibGUI/GTableView.cpp

@@ -318,11 +318,14 @@ void GTableView::doubleclick_event(GMouseEvent& event)
 {
     if (!model())
         return;
+    auto& model = *this->model();
     if (event.button() == GMouseButton::Left) {
         mousedown_event(event);
-        if (is_editable())
-            begin_editing(model()->selected_index());
-        else
-            model()->activate(model()->selected_index());
+        if (model.selected_index().is_valid()) {
+            if (is_editable())
+                begin_editing(model.selected_index());
+            else
+                model.activate(model.selected_index());
+        }
     }
 }