diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-10 13:23:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-11 07:57:56 +0100 |
commit | 14cb12bde07b8becf69b648ecc6642bdccf8a7cd (patch) | |
tree | e616a44bdeb412b518e8f4fcee20f9aaeb8574e9 /sfx2/source/appl | |
parent | 5128bf29d5febceaec51854595f23ae487a0cdec (diff) |
loplugin:refcounting generalise type checking
Change-Id: Ia013878ac9c2918d8eaf9aab16b291d8211e708f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110700
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/appl')
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/appl/shutdownicon.hxx | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 84d169cf708a..40febc9b422a 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -104,7 +104,7 @@ css::uno::Sequence<OUString> SAL_CALL ShutdownIcon::getSupportedServiceNames() } bool ShutdownIcon::bModalMode = false; -ShutdownIcon* ShutdownIcon::pShutdownIcon = nullptr; +rtl::Reference<ShutdownIcon> ShutdownIcon::pShutdownIcon; extern "C" { static void disabled_initSystray() { } @@ -474,23 +474,23 @@ void ShutdownIcon::terminateDesktop() ShutdownIcon* ShutdownIcon::getInstance() { OSL_ASSERT( pShutdownIcon ); - return pShutdownIcon; + return pShutdownIcon.get(); } ShutdownIcon* ShutdownIcon::createInstance() { if (pShutdownIcon) - return pShutdownIcon; + return pShutdownIcon.get(); try { - std::unique_ptr<ShutdownIcon> pIcon(new ShutdownIcon( comphelper::getProcessComponentContext() )); + rtl::Reference<ShutdownIcon> pIcon(new ShutdownIcon( comphelper::getProcessComponentContext() )); pIcon->init (); - pShutdownIcon = pIcon.release(); + pShutdownIcon = pIcon; } catch (...) { } - return pShutdownIcon; + return pShutdownIcon.get(); } void ShutdownIcon::init() diff --git a/sfx2/source/appl/shutdownicon.hxx b/sfx2/source/appl/shutdownicon.hxx index 6829330409de..32113cbc1ee2 100644 --- a/sfx2/source/appl/shutdownicon.hxx +++ b/sfx2/source/appl/shutdownicon.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <osl/mutex.hxx> #include <cppuhelper/compbase.hxx> #include <tools/link.hxx> @@ -68,7 +69,7 @@ class ShutdownIcon : public ShutdownIconServiceBase std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg; css::uno::Reference< css::uno::XComponentContext > m_xContext; - static ShutdownIcon *pShutdownIcon; // one instance + static rtl::Reference<ShutdownIcon> pShutdownIcon; // one instance bool m_bInitialized; void initSystray(); |