[Libreoffice-commits] .: Branch 'libreoffice-3-5-0' - sc/inc
Petr Mladek
pmladek at kemper.freedesktop.org
Wed Feb 1 01:24:49 PST 2012
sc/inc/formularesult.hxx | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
New commits:
commit 6ccf504e590a47bb950aa179590f7e61146c043d
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jan 31 20:40:47 2012 +0100
clone token in ScFormulaResult copy-ctor instead of referring
Replaces commit e2b11f4fd79dce4116badb0ecf6477546ca5d0d4
Prevent excessive references to single token instance during fill.
Because if not, we may run out of the 16-bit integer space to
store reference count.
Signed-off-by: Kohei Yoshida <kohei.yoshida at suse.com>
Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Signed-off-by: Petr Mladek <pmladek at suse.cz>
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 2aa674c..444552f 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -41,6 +41,20 @@ class ScFormulaResult
static const Multiline MULTILINE_FALSE = 1;
static const Multiline MULTILINE_TRUE = 2;
+ // Clone token if the 16-bit only reference counter is nearing it's
+ // capacity during fill or copy&paste, leaving 4k for temporary passing
+ // around. (That should be enough for all times (TM) ;-)
+ static const sal_uInt16 MAX_TOKENREF_COUNT = 0xf000;
+ static void IncrementTokenRef( const formula::FormulaToken* & rp )
+ {
+ if (rp)
+ {
+ if (rp->GetRef() >= MAX_TOKENREF_COUNT)
+ rp = rp->Clone();
+ rp->IncRef();
+ }
+ }
+
union
{
double mfValue; // double result direct for performance and memory consumption
@@ -94,8 +108,12 @@ public:
const ScMatrixFormulaCellToken* pMatFormula =
r.GetMatrixFormulaCellToken();
if (pMatFormula)
+ {
mpToken = new ScMatrixFormulaCellToken( *pMatFormula);
- mpToken->IncRef();
+ mpToken->IncRef();
+ }
+ else
+ IncrementTokenRef( mpToken);
}
}
else
@@ -308,8 +326,7 @@ inline void ScFormulaResult::Assign( const ScFormulaResult & r )
inline void ScFormulaResult::SetToken( const formula::FormulaToken* p )
{
ResetToDefaults();
- if (p)
- p->IncRef();
+ IncrementTokenRef( p);
// Handle a result obtained from the interpreter to be assigned to a matrix
// formula cell's ScMatrixFormulaCellToken.
ScMatrixFormulaCellToken* pMatFormula = GetMatrixFormulaCellTokenNonConst();
More information about the Libreoffice-commits
mailing list