diff options
author | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-03-04 15:19:41 +0100 |
---|---|---|
committer | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-03-04 15:19:41 +0100 |
commit | 709ee7e9b098fa7074d84d3faab7aa5cd5ebf73b (patch) | |
tree | d58e2e95e278a2c864877950904c7bc27dbe3e41 /registry/inc | |
parent | ffca8743e16d5afd101df88aa50f2c8735830e53 (diff) |
mhu22: #i105430# #i108349# Fixed registry:ORegKey reference counting to avoid redundant closeKey()/flush() calls.
Diffstat (limited to 'registry/inc')
-rw-r--r-- | registry/inc/registry/registry.hxx | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/registry/inc/registry/registry.hxx b/registry/inc/registry/registry.hxx index e3ee4574023d..fe31978c5ca0 100644 --- a/registry/inc/registry/registry.hxx +++ b/registry/inc/registry/registry.hxx @@ -486,6 +486,9 @@ public: /// closes explicitly the current key inline RegError closeKey(); + /// releases the current key + inline void releaseKey(); + /** sets a value of a key. @param keyName specifies the name of the key which value will be set. @@ -810,19 +813,18 @@ inline void RegistryKey::setRegistry(Registry& registry) inline RegistryKey::~RegistryKey() { if (m_hImpl) - m_registry.m_pApi->closeKey(m_hImpl); + m_registry.m_pApi->releaseKey(m_hImpl); } inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign) { m_registry = toAssign.m_registry; - if (m_hImpl != toAssign.m_hImpl) - { + if (toAssign.m_hImpl) + m_registry.m_pApi->acquireKey(toAssign.m_hImpl); + if (m_hImpl) m_registry.m_pApi->releaseKey(m_hImpl); - m_hImpl = toAssign.m_hImpl; - m_registry.m_pApi->acquireKey(m_hImpl); - } + m_hImpl = toAssign.m_hImpl; return *this; } @@ -948,6 +950,14 @@ inline RegError RegistryKey::closeKey() return REG_INVALID_KEY; } +inline void RegistryKey::releaseKey() +{ + if (m_registry.isValid() && (m_hImpl != 0)) + { + m_registry.m_pApi->releaseKey(m_hImpl), m_hImpl = 0; + } +} + inline RegError RegistryKey::setValue(const ::rtl::OUString& keyName, RegValueType valueType, RegValue pValue, @@ -1166,15 +1176,13 @@ inline Registry::~Registry() inline Registry& Registry::operator = (const Registry& toAssign) { - - if (m_hImpl != toAssign.m_hImpl) - { - m_pApi->release(m_hImpl); - m_pApi = toAssign.m_pApi; - m_hImpl = toAssign.m_hImpl; - } + if (toAssign.m_hImpl) + toAssign.m_pApi->acquire(toAssign.m_hImpl); if (m_hImpl) - m_pApi->acquire(m_hImpl); + m_pApi->release(m_hImpl); + + m_pApi = toAssign.m_pApi; + m_hImpl = toAssign.m_hImpl; return *this; } |