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

loplugin:useuniqueptr in AcceleratorConfiguration

Change-Id: I255005e80ee57638846e353a88477dd54bbbb284
Reviewed-on: https://gerrit.libreoffice.org/59943
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 9aee9781
...@@ -79,7 +79,6 @@ namespace framework ...@@ -79,7 +79,6 @@ namespace framework
XMLBasedAcceleratorConfiguration::XMLBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext) XMLBasedAcceleratorConfiguration::XMLBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
: m_xContext (xContext ) : m_xContext (xContext )
, m_aPresetHandler(xContext ) , m_aPresetHandler(xContext )
, m_pWriteCache (nullptr )
{ {
} }
...@@ -371,13 +370,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c ...@@ -371,13 +370,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c
{ {
SolarMutexGuard g; SolarMutexGuard g;
xContext = m_xContext; xContext = m_xContext;
if (m_pWriteCache) m_pWriteCache.reset();
{
// be aware of reentrance problems - use temp variable for calling delete ... :-)
AcceleratorCache* pTemp = m_pWriteCache;
m_pWriteCache = nullptr;
delete pTemp;
}
} }
css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY); css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
...@@ -444,10 +437,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c ...@@ -444,10 +437,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
if (bChanged) if (bChanged)
{ {
m_aReadCache.takeOver(*m_pWriteCache); m_aReadCache.takeOver(*m_pWriteCache);
// live with reentrance .-) m_pWriteCache.reset();
AcceleratorCache* pTemp = m_pWriteCache;
m_pWriteCache = nullptr;
delete pTemp;
} }
} }
...@@ -459,7 +449,7 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(bool bWriteAcces ...@@ -459,7 +449,7 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(bool bWriteAcces
//not still possible! //not still possible!
if ( bWriteAccessRequested && !m_pWriteCache ) if ( bWriteAccessRequested && !m_pWriteCache )
{ {
m_pWriteCache = new AcceleratorCache(m_aReadCache); m_pWriteCache.reset(new AcceleratorCache(m_aReadCache));
} }
// in case, we have a writeable cache, we use it for reading too! // in case, we have a writeable cache, we use it for reading too!
...@@ -487,8 +477,6 @@ OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const ...@@ -487,8 +477,6 @@ OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext) XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
: m_xContext (xContext ) : m_xContext (xContext )
, m_pPrimaryWriteCache(nullptr )
, m_pSecondaryWriteCache(nullptr )
{ {
const OUString CFG_ENTRY_ACCELERATORS("org.openoffice.Office.Accelerators"); const OUString CFG_ENTRY_ACCELERATORS("org.openoffice.Office.Accelerators");
m_xCfg.set( m_xCfg.set(
...@@ -765,25 +753,13 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::reload() ...@@ -765,25 +753,13 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::reload()
bPreferred = true; bPreferred = true;
m_aPrimaryReadCache = AcceleratorCache(); m_aPrimaryReadCache = AcceleratorCache();
if (m_pPrimaryWriteCache) m_pPrimaryWriteCache.reset();
{
// be aware of reentrance problems - use temp variable for calling delete ... :-)
AcceleratorCache* pTemp = m_pPrimaryWriteCache;
m_pPrimaryWriteCache = nullptr;
delete pTemp;
}
m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess; m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess;
impl_ts_load(bPreferred, xAccess); // load the preferred keys impl_ts_load(bPreferred, xAccess); // load the preferred keys
bPreferred = false; bPreferred = false;
m_aSecondaryReadCache = AcceleratorCache(); m_aSecondaryReadCache = AcceleratorCache();
if (m_pSecondaryWriteCache) m_pSecondaryWriteCache.reset();
{
// be aware of reentrance problems - use temp variable for calling delete ... :-)
AcceleratorCache* pTemp = m_pSecondaryWriteCache;
m_pSecondaryWriteCache = nullptr;
delete pTemp;
}
m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess; m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess;
impl_ts_load(bPreferred, xAccess); // load the secondary keys impl_ts_load(bPreferred, xAccess); // load the secondary keys
} }
...@@ -1128,9 +1104,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) ...@@ -1128,9 +1104,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
if (m_pPrimaryWriteCache) if (m_pPrimaryWriteCache)
{ {
m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache); m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache);
AcceleratorCache* pTemp = m_pPrimaryWriteCache; m_pPrimaryWriteCache.reset();
m_pPrimaryWriteCache = nullptr;
delete pTemp;
} }
} }
...@@ -1166,9 +1140,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) ...@@ -1166,9 +1140,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
if (m_pSecondaryWriteCache) if (m_pSecondaryWriteCache)
{ {
m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache); m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache);
AcceleratorCache* pTemp = m_pSecondaryWriteCache; m_pSecondaryWriteCache.reset();
m_pSecondaryWriteCache = nullptr;
delete pTemp;
} }
} }
...@@ -1326,7 +1298,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred, ...@@ -1326,7 +1298,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred,
//not still possible! //not still possible!
if ( bWriteAccessRequested && !m_pPrimaryWriteCache ) if ( bWriteAccessRequested && !m_pPrimaryWriteCache )
{ {
m_pPrimaryWriteCache = new AcceleratorCache(m_aPrimaryReadCache); m_pPrimaryWriteCache.reset(new AcceleratorCache(m_aPrimaryReadCache));
} }
// in case, we have a writeable cache, we use it for reading too! // in case, we have a writeable cache, we use it for reading too!
...@@ -1343,7 +1315,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred, ...@@ -1343,7 +1315,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred,
//not still possible! //not still possible!
if ( bWriteAccessRequested && !m_pSecondaryWriteCache ) if ( bWriteAccessRequested && !m_pSecondaryWriteCache )
{ {
m_pSecondaryWriteCache = new AcceleratorCache(m_aSecondaryReadCache); m_pSecondaryWriteCache.reset(new AcceleratorCache(m_aSecondaryReadCache));
} }
// in case, we have a writeable cache, we use it for reading too! // in case, we have a writeable cache, we use it for reading too!
......
...@@ -82,7 +82,7 @@ class XMLBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper< ...@@ -82,7 +82,7 @@ class XMLBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
AcceleratorCache m_aReadCache; AcceleratorCache m_aReadCache;
/** used to implement the copy on write pattern! */ /** used to implement the copy on write pattern! */
AcceleratorCache* m_pWriteCache; std::unique_ptr<AcceleratorCache> m_pWriteCache;
// native interface! // native interface!
...@@ -216,8 +216,8 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper< ...@@ -216,8 +216,8 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
css::uno::Reference< css::container::XNameAccess > m_xCfg; css::uno::Reference< css::container::XNameAccess > m_xCfg;
AcceleratorCache m_aPrimaryReadCache; AcceleratorCache m_aPrimaryReadCache;
AcceleratorCache m_aSecondaryReadCache; AcceleratorCache m_aSecondaryReadCache;
AcceleratorCache* m_pPrimaryWriteCache; std::unique_ptr<AcceleratorCache> m_pPrimaryWriteCache;
AcceleratorCache* m_pSecondaryWriteCache; std::unique_ptr<AcceleratorCache> m_pSecondaryWriteCache;
OUString m_sGlobalOrModules; OUString m_sGlobalOrModules;
OUString m_sModuleCFG; OUString m_sModuleCFG;
......
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