Browse Source

ClipboardHistory: Don't attempt to delete an item if nothing is selected

This prevents a crash if the delete action is invoked using the delete
key while nothing is selected.
Tim Ledbetter 2 years ago
parent
commit
0f831dbcc7
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Userland/Applets/ClipboardHistory/main.cpp

+ 3 - 0
Userland/Applets/ClipboardHistory/main.cpp

@@ -43,6 +43,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     };
 
     auto delete_action = GUI::CommonActions::make_delete_action([&](const GUI::Action&) {
+        if (table_view->selection().is_empty())
+            return;
+
         model->remove_item(table_view->selection().first().row());
     });