[Libreoffice-bugs] [Bug 133898] Call to loadCalendarTZ crashes LibreOffice

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Jun 11 15:28:46 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=133898

--- Comment #5 from Julien Nabet <serval2412 at yahoo.fr> ---
(In reply to Mike Kaganski from comment #4)
> (In reply to Julien Nabet from comment #2)
> > The pb here is we got no context.
> 
> Try introducing a local variable for context, assign it to m_xContext if
> it's valid, or to comphelper::getProcessComponentContext() otherwise; and
> use this local variable in place of m_xContext there?

What about using comphelper::getProcessComponentContext() in the ctr where
context isn't provided by arg?
Also for the second ctr, if context provided by arg is empty, I'd use
comphelper::getProcessComponentContext() too, what do you think?

if you don't want ctrs be modified, I could change this block:
     70     if (i >= sal::static_int_cast<sal_Int32>(lookupTable.size())) {
     71         Reference < XInterface > xI =
m_xContext->getServiceManager()->createInstanceWithContext(
     72                   "com.sun.star.i18n.Calendar_" + uniqueID,
m_xContext);
     73 
     74         if ( ! xI.is() ) {
     75             // check if the calendar is defined in localedata, load
gregorian calendar service.
     76             const Sequence< Calendar2 > xC =
LocaleDataImpl::get()->getAllCalendars2(rLocale);
     77             if (std::any_of(xC.begin(), xC.end(), [&uniqueID](const
Calendar2& rCal) { return uniqueID == rCal.Name; }))
     78                 xI =
m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.i18n.Calendar_gregorian",
m_xContext);
     79         }

by:
     70     if (i >= sal::static_int_cast<sal_Int32>(lookupTable.size())) {
++                if (!m_xContext.is())
++                    m_xContext = comphelper::getProcessComponentContext();
     71         Reference < XInterface > xI =
m_xContext->getServiceManager()->createInstanceWithContext(
     72                   "com.sun.star.i18n.Calendar_" + uniqueID,
m_xContext);
     73 
     74         if ( ! xI.is() ) {
     75             // check if the calendar is defined in localedata, load
gregorian calendar service.
     76             const Sequence< Calendar2 > xC =
LocaleDataImpl::get()->getAllCalendars2(rLocale);
     77             if (std::any_of(xC.begin(), xC.end(), [&uniqueID](const
Calendar2& rCal) { return uniqueID == rCal.Name; }))
     78                 xI =
m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.i18n.Calendar_gregorian",
m_xContext);
     79         }

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200611/11336f04/attachment.htm>


More information about the Libreoffice-bugs mailing list