From 545f5f8abd1df1f9818fbc62c95006149bcc18ef Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 11 Nov 2016 21:17:01 -0500 Subject: [PATCH] Guarantee that InterpretFormulaGroup() is always called first. This makes it easier to profile group calculations via formula log. You can always bail out of that function when unfavorable condition hits. Change-Id: I49664c3e34b9efc98f39845379631649f76769de Reviewed-on: https://gerrit.libreoffice.org/30790 Reviewed-by: Kohei Yoshida Tested-by: Kohei Yoshida --- sc/source/core/data/formulacell.cxx | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 6231bc6bdf57..8b2e62a71303 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1537,24 +1537,16 @@ void ScFormulaCell::Interpret() } else { - // Do not attempt to interpret a group when calculations are already - // running, otherwise we may run into a circular reference hell. See - // tdf#95748 - if (rRecursionHelper.GetRecursionCount()) - InterpretTail( SCITP_NORMAL); - else - { #if DEBUG_CALCULATION - aDC.enterGroup(); - bool bGroupInterpreted = InterpretFormulaGroup(); - aDC.leaveGroup(); - if (!bGroupInterpreted) - InterpretTail( SCITP_NORMAL); + aDC.enterGroup(); + bool bGroupInterpreted = InterpretFormulaGroup(); + aDC.leaveGroup(); + if (!bGroupInterpreted) + InterpretTail( SCITP_NORMAL); #else - if (!InterpretFormulaGroup()) - InterpretTail( SCITP_NORMAL); + if (!InterpretFormulaGroup()) + InterpretTail( SCITP_NORMAL); #endif - } } // While leaving a recursion or iteration stack, insert its cells to the @@ -4033,6 +4025,15 @@ bool ScFormulaCell::InterpretFormulaGroup() auto aScope = sc::FormulaLogger::get().enterGroup(*pDocument, *this); + if (pDocument->GetRecursionHelper().GetRecursionCount()) + { + // Do not attempt to interpret a group when calculations are already + // running, otherwise we may run into a circular reference hell. See + // tdf#95748 + aScope.addMessage("group calc disabled during recursive calculation."); + return false; + } + if (mxGroup->meCalcState == sc::GroupCalcDisabled) { aScope.addMessage("group calc disabled");