From 391d1ddfd87dc3cd77783e62299fb1df956ad3ce Mon Sep 17 00:00:00 2001 From: David Isaksson Date: Tue, 23 Mar 2021 22:08:16 +0100 Subject: [PATCH] Spreadsheet: Ensure that cell exists on drop event for text data Fixes crash where we tried to get a cell to set text from the drop event. We now create the cell if it does not already exists. Fixes issue #5923 --- Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 8e49a2b1624..1f3bf0ae9aa 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -297,10 +297,8 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) } if (event.mime_data().has_text()) { - auto* target_cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); - VERIFY(target_cell); - - target_cell->set_data(event.text()); + auto& target_cell = m_sheet->ensure({ (size_t)index.column(), (size_t)index.row() }); + target_cell.set_data(event.text()); return; } };