Kaydet (Commit) f05f4e04 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SvpSalInstance

Change-Id: I8cab3c63ba4dcd08488d0fb34d689692d5cf97f9
Reviewed-on: https://gerrit.libreoffice.org/59347
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 82034b04
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <unx/gendata.hxx> #include <unx/gendata.hxx>
#include <headless/svpinst.hxx> #include <headless/svpinst.hxx>
#include <o3tl/make_unique.hxx>
class SvpSalData : public GenericUnixSalData class SvpSalData : public GenericUnixSalData
{ {
...@@ -21,7 +22,7 @@ public: ...@@ -21,7 +22,7 @@ public:
// plugin factory function // plugin factory function
SalInstance* svp_create_SalInstance() SalInstance* svp_create_SalInstance()
{ {
SvpSalInstance* pInstance = new SvpSalInstance( new SvpSalYieldMutex() ); SvpSalInstance* pInstance = new SvpSalInstance( o3tl::make_unique<SvpSalYieldMutex>() );
new SvpSalData( pInstance ); new SvpSalData( pInstance );
return pInstance; return pInstance;
} }
......
...@@ -63,8 +63,8 @@ static void atfork_child() ...@@ -63,8 +63,8 @@ static void atfork_child()
#endif #endif
SvpSalInstance::SvpSalInstance( SalYieldMutex *pMutex ) SvpSalInstance::SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex )
: SalGenericInstance( pMutex ) : SalGenericInstance( std::move(pMutex) )
{ {
m_aTimeout.tv_sec = 0; m_aTimeout.tv_sec = 0;
m_aTimeout.tv_usec = 0; m_aTimeout.tv_usec = 0;
......
...@@ -112,7 +112,7 @@ class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance, public SalUserEv ...@@ -112,7 +112,7 @@ class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance, public SalUserEv
public: public:
static SvpSalInstance* s_pDefaultInstance; static SvpSalInstance* s_pDefaultInstance;
SvpSalInstance( SalYieldMutex *pMutex ); SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex );
virtual ~SvpSalInstance() override; virtual ~SvpSalInstance() override;
void CloseWakeupPipe(bool log); void CloseWakeupPipe(bool log);
......
...@@ -54,7 +54,7 @@ Q_SIGNALS: ...@@ -54,7 +54,7 @@ Q_SIGNALS:
bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents); bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
public: public:
explicit Qt5Instance(SalYieldMutex* pMutex, bool bUseCairo = false); explicit Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo = false);
virtual ~Qt5Instance() override; virtual ~Qt5Instance() override;
virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override; virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
......
...@@ -47,8 +47,8 @@ protected: ...@@ -47,8 +47,8 @@ protected:
std::unique_ptr<SalYieldMutex> mpSalYieldMutex; std::unique_ptr<SalYieldMutex> mpSalYieldMutex;
public: public:
SalGenericInstance( SalYieldMutex* pMutex ) SalGenericInstance( std::unique_ptr<SalYieldMutex> pMutex )
: mbPrinterInit( false ), mpSalYieldMutex( pMutex ) {} : mbPrinterInit( false ), mpSalYieldMutex( std::move(pMutex) ) {}
virtual ~SalGenericInstance() override; virtual ~SalGenericInstance() override;
// Yield mutex // Yield mutex
......
...@@ -184,7 +184,7 @@ class GtkInstance : public X11SalInstance ...@@ -184,7 +184,7 @@ class GtkInstance : public X11SalInstance
typedef X11SalInstance Superclass_t; typedef X11SalInstance Superclass_t;
#endif #endif
public: public:
GtkInstance( SalYieldMutex* pMutex ); GtkInstance( std::unique_ptr<SalYieldMutex> pMutex );
virtual ~GtkInstance() override; virtual ~GtkInstance() override;
void EnsureInit(); void EnsureInit();
virtual void AfterAppInit() override; virtual void AfterAppInit() override;
......
...@@ -47,7 +47,7 @@ protected: ...@@ -47,7 +47,7 @@ protected:
virtual SalX11Display* CreateDisplay() const; virtual SalX11Display* CreateDisplay() const;
public: public:
explicit X11SalInstance(SalYieldMutex* pMutex); explicit X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex);
virtual ~X11SalInstance() override; virtual ~X11SalInstance() override;
virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override; virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#include <headless/svpbmp.hxx> #include <headless/svpbmp.hxx>
Qt5Instance::Qt5Instance(SalYieldMutex* pMutex, bool bUseCairo) Qt5Instance::Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo)
: SalGenericInstance(pMutex) : SalGenericInstance(std::move(pMutex))
, m_postUserEventId(-1) , m_postUserEventId(-1)
, m_bUseCairo(bUseCairo) , m_bUseCairo(bUseCairo)
{ {
...@@ -287,7 +287,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance() ...@@ -287,7 +287,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
static const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO")); static const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO"));
Qt5Instance* pInstance = new Qt5Instance(new SalYieldMutex(), bUseCairo); Qt5Instance* pInstance = new Qt5Instance(o3tl::make_unique<SalYieldMutex>(), bUseCairo);
// initialize SalData // initialize SalData
new Qt5Data(pInstance); new Qt5Data(pInstance);
......
...@@ -54,7 +54,7 @@ extern "C" ...@@ -54,7 +54,7 @@ extern "C"
if( ! ( pNoXInitThreads && *pNoXInitThreads ) ) if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
XInitThreads(); XInitThreads();
X11SalInstance* pInstance = new X11SalInstance( new SalYieldMutex() ); X11SalInstance* pInstance = new X11SalInstance( o3tl::make_unique<SalYieldMutex>() );
// initialize SalData // initialize SalData
X11SalData *pSalData = new X11SalData( SAL_DATA_UNX, pInstance ); X11SalData *pSalData = new X11SalData( SAL_DATA_UNX, pInstance );
...@@ -66,8 +66,8 @@ extern "C" ...@@ -66,8 +66,8 @@ extern "C"
} }
} }
X11SalInstance::X11SalInstance(SalYieldMutex* pMutex) X11SalInstance::X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex)
: SalGenericInstance(pMutex) : SalGenericInstance(std::move(pMutex))
, mpXLib(nullptr) , mpXLib(nullptr)
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
......
...@@ -91,8 +91,6 @@ extern "C" ...@@ -91,8 +91,6 @@ extern "C"
} }
#endif #endif
GtkYieldMutex *pYieldMutex;
// init gdk thread protection // init gdk thread protection
bool const sup = g_thread_supported(); bool const sup = g_thread_supported();
// extracted from the 'if' to avoid Clang -Wunreachable-code // extracted from the 'if' to avoid Clang -Wunreachable-code
...@@ -102,11 +100,11 @@ extern "C" ...@@ -102,11 +100,11 @@ extern "C"
gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave); gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave);
SAL_INFO("vcl.gtk", "Hooked gdk threads locks"); SAL_INFO("vcl.gtk", "Hooked gdk threads locks");
pYieldMutex = new GtkYieldMutex(); auto pYieldMutex = o3tl::make_unique<GtkYieldMutex>();
gdk_threads_init(); gdk_threads_init();
GtkInstance* pInstance = new GtkInstance( pYieldMutex ); GtkInstance* pInstance = new GtkInstance( std::move(pYieldMutex) );
SAL_INFO("vcl.gtk", "creating GtkInstance " << pInstance); SAL_INFO("vcl.gtk", "creating GtkInstance " << pInstance);
// Create SalData, this does not leak // Create SalData, this does not leak
...@@ -147,11 +145,11 @@ static VclInputFlags categorizeEvent(const GdkEvent *pEvent) ...@@ -147,11 +145,11 @@ static VclInputFlags categorizeEvent(const GdkEvent *pEvent)
} }
#endif #endif
GtkInstance::GtkInstance( SalYieldMutex* pMutex ) GtkInstance::GtkInstance( std::unique_ptr<SalYieldMutex> pMutex )
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
: SvpSalInstance( pMutex ) : SvpSalInstance( std::move(pMutex) )
#else #else
: X11SalInstance( pMutex ) : X11SalInstance( std::move(pMutex) )
#endif #endif
, m_pTimer(nullptr) , m_pTimer(nullptr)
, bNeedsInit(true) , bNeedsInit(true)
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
using namespace com::sun::star; using namespace com::sun::star;
KDESalInstance::KDESalInstance(SalYieldMutex* pMutex) KDESalInstance::KDESalInstance(std::unique_ptr<SalYieldMutex> pMutex)
: X11SalInstance(pMutex) : X11SalInstance(std::move(pMutex))
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
delete pSVData->maAppData.mpToolkitName; delete pSVData->maAppData.mpToolkitName;
......
...@@ -30,7 +30,7 @@ protected: ...@@ -30,7 +30,7 @@ protected:
virtual SalX11Display* CreateDisplay() const override; virtual SalX11Display* CreateDisplay() const override;
public: public:
explicit KDESalInstance(SalYieldMutex* pMutex); explicit KDESalInstance(std::unique_ptr<SalYieldMutex> pMutex);
virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override; virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
virtual bool hasNativeFileSelection() const override { return true; } virtual bool hasNativeFileSelection() const override { return true; }
......
...@@ -73,7 +73,7 @@ extern "C" { ...@@ -73,7 +73,7 @@ extern "C" {
} }
#endif #endif
KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() ); KDESalInstance* pInstance = new KDESalInstance( o3tl::make_unique<SalYieldMutex>() );
SAL_INFO( "vcl.kde4", "created KDESalInstance " << &pInstance ); SAL_INFO( "vcl.kde4", "created KDESalInstance " << &pInstance );
// initialize SalData // initialize SalData
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment