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

loplugin:useuniqueptr in LngSvcMgr

Change-Id: I3c8046a70ffce402d52caf2e7b77fa9951103f99
Reviewed-on: https://gerrit.libreoffice.org/59011
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 17838c9c
......@@ -417,11 +417,6 @@ LngSvcMgr::LngSvcMgr()
{
bDisposing = false;
pAvailSpellSvcs = nullptr;
pAvailGrammarSvcs = nullptr;
pAvailHyphSvcs = nullptr;
pAvailThesSvcs = nullptr;
// request notify events when properties (i.e. something in the subtree) changes
uno::Sequence< OUString > aNames(4);
OUString *pNames = aNames.getArray();
......@@ -464,10 +459,10 @@ void LngSvcMgr::modified(const lang::EventObject&)
//assume that if an extension has been added/removed that
//it might be a dictionary extension, so drop our cache
clearSvcInfoArray(pAvailSpellSvcs);
clearSvcInfoArray(pAvailGrammarSvcs);
clearSvcInfoArray(pAvailHyphSvcs);
clearSvcInfoArray(pAvailThesSvcs);
pAvailSpellSvcs.reset();
pAvailGrammarSvcs.reset();
pAvailHyphSvcs.reset();
pAvailThesSvcs.reset();
}
{
......@@ -521,12 +516,6 @@ void LngSvcMgr::disposing(const lang::EventObject&)
stopListening();
}
void LngSvcMgr::clearSvcInfoArray(SvcInfoArray* &rpInfo)
{
delete rpInfo;
rpInfo = nullptr;
}
LngSvcMgr::~LngSvcMgr()
{
stopListening();
......@@ -535,10 +524,10 @@ LngSvcMgr::~LngSvcMgr()
// will be freed in the destructor of the respective Reference's
// xSpellDsp, xGrammarDsp, xHyphDsp, xThesDsp
clearSvcInfoArray(pAvailSpellSvcs);
clearSvcInfoArray(pAvailGrammarSvcs);
clearSvcInfoArray(pAvailHyphSvcs);
clearSvcInfoArray(pAvailThesSvcs);
pAvailSpellSvcs.reset();
pAvailGrammarSvcs.reset();
pAvailHyphSvcs.reset();
pAvailThesSvcs.reset();
}
namespace
......@@ -801,7 +790,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
osl::MutexGuard aGuard(GetLinguMutex());
// delete old cached data, needs to be acquired new on demand
clearSvcInfoArray(pAvailSpellSvcs);
pAvailSpellSvcs.reset();
if (lcl_SeqHasString( aSpellCheckerListEntries, aKeyText ))
{
......@@ -824,7 +813,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
osl::MutexGuard aGuard(GetLinguMutex());
// delete old cached data, needs to be acquired new on demand
clearSvcInfoArray(pAvailGrammarSvcs);
pAvailGrammarSvcs.reset();
if (lcl_SeqHasString( aGrammarCheckerListEntries, aKeyText ))
{
......@@ -850,7 +839,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
osl::MutexGuard aGuard(GetLinguMutex());
// delete old cached data, needs to be acquired new on demand
clearSvcInfoArray(pAvailHyphSvcs);
pAvailHyphSvcs.reset();
if (lcl_SeqHasString( aHyphenatorListEntries, aKeyText ))
{
......@@ -873,7 +862,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
osl::MutexGuard aGuard(GetLinguMutex());
// delete old cached data, needs to be acquired new on demand
clearSvcInfoArray(pAvailThesSvcs);
pAvailThesSvcs.reset();
if (lcl_SeqHasString( aThesaurusListEntries, aKeyText ))
{
......@@ -980,7 +969,7 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl()
{
if (!pAvailSpellSvcs)
{
pAvailSpellSvcs = new SvcInfoArray;
pAvailSpellSvcs.reset(new SvcInfoArray);
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
......@@ -1042,7 +1031,7 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl()
{
if (!pAvailGrammarSvcs)
{
pAvailGrammarSvcs = new SvcInfoArray;
pAvailGrammarSvcs.reset(new SvcInfoArray);
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
......@@ -1105,7 +1094,7 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl()
{
if (!pAvailHyphSvcs)
{
pAvailHyphSvcs = new SvcInfoArray;
pAvailHyphSvcs.reset(new SvcInfoArray);
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY );
......@@ -1165,7 +1154,7 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
{
if (!pAvailThesSvcs)
{
pAvailThesSvcs = new SvcInfoArray;
pAvailThesSvcs.reset(new SvcInfoArray);
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
......@@ -1472,22 +1461,22 @@ uno::Sequence< OUString > SAL_CALL
if (rServiceName == SN_SPELLCHECKER)
{
GetAvailableSpellSvcs_Impl();
pInfoArray = pAvailSpellSvcs;
pInfoArray = pAvailSpellSvcs.get();
}
else if (rServiceName == SN_GRAMMARCHECKER)
{
GetAvailableGrammarSvcs_Impl();
pInfoArray = pAvailGrammarSvcs;
pInfoArray = pAvailGrammarSvcs.get();
}
else if (rServiceName == SN_HYPHENATOR)
{
GetAvailableHyphSvcs_Impl();
pInfoArray = pAvailHyphSvcs;
pInfoArray = pAvailHyphSvcs.get();
}
else if (rServiceName == SN_THESAURUS)
{
GetAvailableThesSvcs_Impl();
pInfoArray = pAvailThesSvcs;
pInfoArray = pAvailThesSvcs.get();
}
if (pInfoArray)
......
......@@ -91,10 +91,10 @@ class LngSvcMgr :
rtl::Reference<LngSvcMgrListenerHelper> mxListenerHelper;
typedef std::vector< std::unique_ptr<SvcInfo> > SvcInfoArray;
SvcInfoArray * pAvailSpellSvcs;
SvcInfoArray * pAvailGrammarSvcs;
SvcInfoArray * pAvailHyphSvcs;
SvcInfoArray * pAvailThesSvcs;
std::unique_ptr<SvcInfoArray> pAvailSpellSvcs;
std::unique_ptr<SvcInfoArray> pAvailGrammarSvcs;
std::unique_ptr<SvcInfoArray> pAvailHyphSvcs;
std::unique_ptr<SvcInfoArray> pAvailThesSvcs;
bool bDisposing;
......@@ -119,8 +119,6 @@ class LngSvcMgr :
bool SaveCfgSvcs( const OUString &rServiceName );
static void clearSvcInfoArray(SvcInfoArray *&rpInfo);
// utl::ConfigItem (to allow for listening of changes of relevant properties)
virtual void Notify( const css::uno::Sequence< OUString > &rPropertyNames ) override;
virtual void ImplCommit() override;
......
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