Ver Fonte

Spreadsheet: Handle case when drag-and-drop location is out of bounds

When the drop location of a drag-and-drop operation is not valid, then
don't continue with the drop_event. For example, if the ending location
is the header row or header column, or is outside of the table, then
should not continue.
martinfalisse há 3 anos atrás
pai
commit
5759b25ca8
1 ficheiros alterados com 4 adições e 1 exclusões
  1. 4 1
      Userland/Applications/Spreadsheet/SpreadsheetView.cpp

+ 4 - 1
Userland/Applications/Spreadsheet/SpreadsheetView.cpp

@@ -246,9 +246,12 @@ void InfinitelyScrollableTableView::mouseup_event(GUI::MouseEvent& event)
 
 void InfinitelyScrollableTableView::drop_event(GUI::DropEvent& event)
 {
-    TableView::drop_event(event);
     m_is_dragging_for_cut = false;
     set_override_cursor(Gfx::StandardCursor::Arrow);
+    if (!index_at_event_position(event.position()).is_valid())
+        return;
+
+    TableView::drop_event(event);
     auto drop_index = index_at_event_position(event.position());
     if (selection().size() > 0) {
         // Get top left index position of previous selection