summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-12-22 14:55:01 +0300
committerXisco Fauli <xiscofauli@libreoffice.org>2021-12-23 21:30:24 +0100
commit29ec800034211194f9e2ab1748e0b6a1011dcf3f (patch)
treee2c8609cbe20e18aea0868eb16f43d8bf8b08189 /scripting
parentd5c8e1e0ddda213b3d4d64510259dba45315518e (diff)
tdf#143582: Avoid error on clearing leftover return value of a method
SbxValue::Clear happens to not error out on clearing string and some other types of objects, but for the rest, it calls SbxValue::Put, and the latter errors out if not CanWrite(). The original test implemented in commit 24d24debef4cda7de702c4b470a3707f1aae3ea3 only checked string return value, so happened to miss this problem. See similar code in SbiRuntime::FindElement. Change-Id: I7c17137cc9e7ee3133ee86a9f701559df66e53b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127248 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 822998f1dc202aba7a558767f641687aef0c1148) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127257 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/basscript.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx
index 0b411c83f180..2cc67d4feb05 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -245,7 +245,10 @@ constexpr OUStringLiteral BASSCRIPT_PROPERTY_CALLER = u"Caller";
aOldThisComponent = m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( m_xDocumentScriptContext ) );
// tdf#143582 - clear return value of the method before calling it
+ const SbxFlagBits nSavFlags = m_xMethod->GetFlags();
+ m_xMethod->SetFlag(SbxFlagBits::ReadWrite | SbxFlagBits::NoBroadcast);
m_xMethod->Clear();
+ m_xMethod->SetFlags(nSavFlags);
if ( m_caller.hasElements() && m_caller[ 0 ].hasValue() )
{
SbxVariableRef xCallerVar = new SbxVariable( SbxVARIANT );