what's with the static uno::References in Foo_CreateInstance ?

Stephan Bergmann sbergman at redhat.com
Mon Feb 16 08:58:34 PST 2015


On 02/16/2015 04:29 PM, Caolán McNamara wrote:
> uno::Reference< uno::XInterface > SAL_CALL AnalysisAddIn_CreateInstance(
>          const uno::Reference< lang::XMultiServiceFactory >& xServiceFact
> )
> {
>      static uno::Reference< uno::XInterface > xInst =
>         (cppu::OWeakObject*) new AnalysisAddIn(...);
>      return xInst;
> }
>
> now, the above is an argument to createOneInstanceFactory. So it's only
> going to be called once anyway, right ? So if the intent is to ensure
> it's a singleton then that's unnecessary.
>
> Some grepping shows that this is a fairly common calc theme, but rare
> elsewhere.

Yes, should be completely unnecessary.


More information about the LibreOffice mailing list