sc/source/ui/view/viewfunc.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
New commits: commit d96527e9fdf2b981c176a0821b21d75203ee5950 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Oct 7 20:12:17 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Oct 8 11:48:53 2024 +0200 Resolves: tdf#163275 crash in async dialog use after free since: commit b39c6082aa975ed8e5696c3dc24c3025ed07bbb6 CommitDate: Wed Jan 31 10:33:48 2024 +0100 Implement Async AutoCorrectQuery Dialogs for Formula Check in calc Change-Id: Ie184f72cfa858ed1fc6d9eb5205dea985767eec5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174644 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index a0de9ffc3942..955076030e4d 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -143,7 +143,7 @@ struct FormulaProcessingContext std::shared_ptr<ScTokenArray> pArr; std::shared_ptr<ScTokenArray> pArrFirst; - const EditTextObject* pData; + std::shared_ptr<EditTextObject> xTextObject; ScMarkData aMark; ScViewFunc& rViewFunc; @@ -558,10 +558,10 @@ namespace if (nType == SvNumFormatType::TEXT || ((context->aString[0] == '+' || context->aString[0] == '-') && nError != FormulaError::NONE && context->aString == context->aFormula)) { - if ( context->pData ) + if ( context->xTextObject ) { - // A clone of context->pData will be stored in the cell. - context->GetDocFunc().SetEditCell(*(context->aPos), *context->pData, true); + // A clone of context->xTextObject will be stored in the cell. + context->GetDocFunc().SetEditCell(*(context->aPos), *context->xTextObject, true); } else context->GetDocFunc().SetStringCell(*(context->aPos), context->aFormula, true); @@ -725,6 +725,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, i = aMark.GetFirstSelected(); auto xPosPtr = std::make_shared<ScAddress>(nCol, nRow, i); auto xCompPtr = std::make_shared<ScCompiler>(rDoc, *xPosPtr, rDoc.GetGrammar(), true, false); + std::unique_ptr<EditTextObject> xTextObject(pData ? pData->Clone() : nullptr); //2do: enable/disable autoCorrection via calcoptions xCompPtr->SetAutoCorrection( true ); @@ -736,10 +737,10 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString aFormula( rString ); FormulaProcessingContext context_instance{ - std::move(xPosPtr), std::move(xCompPtr), std::move(xModificator), nullptr, - nullptr, pData, std::move(aMark), *this, - OUString(), aFormula, rString, nCol, - nRow, nTab, bMatrixExpand, bNumFmtChanged, + std::move(xPosPtr), std::move(xCompPtr), std::move(xModificator), nullptr, + nullptr, std::move(xTextObject), std::move(aMark), *this, + OUString(), aFormula, rString, nCol, + nRow, nTab, bMatrixExpand, bNumFmtChanged, bRecord };