From ef2db349f8fc7a1bc2b918b505d76bb0b6e1c467 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 7 May 2022 17:13:56 +0800 Subject: [PATCH] Spreadsheet: fix cell clearing --- src/Mod/Spreadsheet/App/Sheet.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 477d496b03..e0fc1a60e4 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -1080,21 +1080,19 @@ short Sheet::mustExecute(void) const void Sheet::clear(CellAddress address, bool /*all*/) { - Cell * cell = getCell(address); - if (!cell) - return; + if (auto cell = getCell(address)) { + // Remove alias, if defined + std::string aliasStr; + if (cell->getAlias(aliasStr)) + this->removeDynamicProperty(aliasStr.c_str()); + cells.clear(address); + } + std::string addr = address.toString(); - Property * prop = props.getDynamicPropertyByName(addr.c_str()); - - // Remove alias, if defined - std::string aliasStr; - if (cell->getAlias(aliasStr)) - this->removeDynamicProperty(aliasStr.c_str()); - - cells.clear(address); - - propAddress.erase(prop); - this->removeDynamicProperty(addr.c_str()); + if (auto prop = props.getDynamicPropertyByName(addr.c_str())) { + propAddress.erase(prop); + this->removeDynamicProperty(addr.c_str()); + } } /**