Explorar o código

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 %!s(int64=3) %!d(string=hai) anos
pai
achega
5759b25ca8
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  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)
 void InfinitelyScrollableTableView::drop_event(GUI::DropEvent& event)
 {
 {
-    TableView::drop_event(event);
     m_is_dragging_for_cut = false;
     m_is_dragging_for_cut = false;
     set_override_cursor(Gfx::StandardCursor::Arrow);
     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());
     auto drop_index = index_at_event_position(event.position());
     if (selection().size() > 0) {
     if (selection().size() > 0) {
         // Get top left index position of previous selection
         // Get top left index position of previous selection