summaryrefslogtreecommitdiff
path: root/connectivity/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-06-15 15:34:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-06-15 18:39:31 +0200
commite469a171833c2d88c4e129f339415c15a3a14b1e (patch)
treef6b7a46fa3f231adb06dd14219d489539531af2c /connectivity/source
parent1a253362f6d1e1909913dce298630c92d431e41e (diff)
wrap OSQLParser::s_xLocaleData in vcl::DeleteOnDeinit
since my adaption of i18npool to use OUStringLiteral, this data structure might get torn down after the i18npool data is has pointers to. Change-Id: If83d232d5bfb003ed4dbfb70d47f707a73d2bcc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153121 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source')
-rw-r--r--connectivity/source/parse/sqlbison.y2
-rw-r--r--connectivity/source/parse/sqlnode.cxx15
2 files changed, 8 insertions, 9 deletions
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index cbad86149fc2..0c5d359d083e 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -4493,7 +4493,7 @@ sal_Int32 OSQLParser::s_nRefCount = 0;
// ::osl::Mutex OSQLParser::s_aMutex;
OSQLScanner* OSQLParser::s_pScanner = nullptr;
OSQLParseNodesGarbageCollector* OSQLParser::s_pGarbageCollector = nullptr;
-css::uno::Reference< css::i18n::XLocaleData4> OSQLParser::s_xLocaleData = nullptr;
+vcl::DeleteOnDeinit<css::uno::Reference< css::i18n::XLocaleData4>> OSQLParser::s_xLocaleData(vcl::DeleteOnDeinitFlag::Empty);
void setParser(OSQLParser* _pParser)
{
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 4f213bf4f902..1153a216cffd 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -803,7 +803,7 @@ void OSQLParser::killThousandSeparator(OSQLParseNode* pLiteral)
{
if ( pLiteral )
{
- if ( s_xLocaleData->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
+ if ( s_xLocaleData.get()->get()->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
{
pLiteral->m_aNodeValue = pLiteral->m_aNodeValue.replace('.', sal_Unicode());
// and replace decimal
@@ -1118,7 +1118,7 @@ OUString OSQLParser::stringToDouble(const OUString& _rValue,sal_Int16 _nScale)
OUString aValue;
if(!m_xCharClass.is())
m_xCharClass = CharacterClassification::create( m_xContext );
- if( s_xLocaleData.is() )
+ if( s_xLocaleData.get() )
{
try
{
@@ -1129,7 +1129,8 @@ OUString OSQLParser::stringToDouble(const OUString& _rValue,sal_Int16 _nScale)
sal_Int32 nPos = aValue.lastIndexOf('.');
if((nPos+_nScale) < aValue.getLength())
aValue = aValue.replaceAt(nPos+_nScale,aValue.getLength()-nPos-_nScale, u"");
- aValue = aValue.replaceAt(aValue.lastIndexOf('.'),1,s_xLocaleData->getLocaleItem(m_pData->aLocale).decimalSeparator);
+ OUString sDecimalSeparator = s_xLocaleData.get()->get()->getLocaleItem(m_pData->aLocale).decimalSeparator;
+ aValue = aValue.replaceAt(aValue.lastIndexOf('.'), 1, sDecimalSeparator);
return aValue;
}
}
@@ -1247,7 +1248,7 @@ std::unique_ptr<OSQLParseNode> OSQLParser::predicateTree(OUString& rErrorMessage
s_pScanner->SetRule(OSQLScanner::GetSTRINGRule());
break;
default:
- if ( s_xLocaleData->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
+ if ( s_xLocaleData.get()->get()->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
s_pScanner->SetRule(OSQLScanner::GetGERRule());
else
s_pScanner->SetRule(OSQLScanner::GetENGRule());
@@ -1330,8 +1331,8 @@ OSQLParser::OSQLParser(css::uno::Reference< css::uno::XComponentContext > xConte
s_pScanner->setScanner();
s_pGarbageCollector = new OSQLParseNodesGarbageCollector();
- if(!s_xLocaleData.is())
- s_xLocaleData = LocaleData::create(m_xContext);
+ if(!s_xLocaleData.get())
+ s_xLocaleData.set(LocaleData::create(m_xContext));
// reset to UNKNOWN_RULE
static_assert(OSQLParseNode::UNKNOWN_RULE==0, "UNKNOWN_RULE must be 0 for memset to 0 to work");
@@ -1482,8 +1483,6 @@ OSQLParser::~OSQLParser()
delete s_pGarbageCollector;
s_pGarbageCollector = nullptr;
- // Is only set the first time, so we should delete it only when there are no more instances
- s_xLocaleData = nullptr;
RuleIDMap().swap(s_aReverseRuleIDLookup);
}