From 28428beb5c297148a89bd82471b903bdb7e8f10a Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sun, 20 Dec 2020 12:44:43 +0330 Subject: [PATCH] Spreadsheet: Accept (and ignore) invalid 'columns' in json The save functionality omits these when the names are standard, so just ignore them if they don't exist (or are not valid). --- Applications/Spreadsheet/Spreadsheet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Applications/Spreadsheet/Spreadsheet.cpp b/Applications/Spreadsheet/Spreadsheet.cpp index 90240cc239..e26740de31 100644 --- a/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Applications/Spreadsheet/Spreadsheet.cpp @@ -373,8 +373,6 @@ RefPtr Sheet::from_json(const JsonObject& object, Workbook& workbook) auto sheet = adopt(*new Sheet(workbook)); auto rows = object.get("rows").to_u32(default_row_count); auto columns = object.get("columns"); - if (!columns.is_array()) - return nullptr; auto name = object.get("name").as_string_or("Sheet"); sheet->set_name(name); @@ -383,10 +381,12 @@ RefPtr Sheet::from_json(const JsonObject& object, Workbook& workbook) sheet->add_row(); // FIXME: Better error checking. - columns.as_array().for_each([&](auto& value) { - sheet->m_columns.append(value.as_string()); - return IterationDecision::Continue; - }); + if (columns.is_array()) { + columns.as_array().for_each([&](auto& value) { + sheet->m_columns.append(value.as_string()); + return IterationDecision::Continue; + }); + } if (sheet->m_columns.size() < default_column_count && sheet->columns_are_standard()) { for (size_t i = sheet->m_columns.size(); i < default_column_count; ++i)