summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-05-29 14:42:06 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2019-05-31 13:22:58 +0200
commit7d582d1f9767c0ebd5e319f2fd11711e60cd72fa (patch)
tree21e6c464719bf2f90e153d06214e932a132cc968 /dbaccess/source
parent6f613f973dcb86dbebc212bc466fbaa2b002655b (diff)
dbaccess: fix more memory leaks caused by circular Reference
Followup to 96ae2a3300811897c24cccb20f8c2faf382483df; more overridden acquire() creating cycles in dbaccess. (regression from 2660d24a07866e083c5135ea263030f3e3a2e729) Change-Id: I134343b3afbcd5ee3f71212ec18e551455eaee5b Reviewed-on: https://gerrit.libreoffice.org/73158 Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> Tested-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/core/dataaccess/ComponentDefinition.cxx16
-rw-r--r--dbaccess/source/core/dataaccess/ComponentDefinition.hxx3
-rw-r--r--dbaccess/source/ui/misc/singledoccontroller.cxx12
3 files changed, 18 insertions, 13 deletions
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
index 41de9c5f995c..1d0d30e88542 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -157,9 +157,10 @@ Sequence< OUString > SAL_CALL OComponentDefinition::getSupportedServiceNames()
void SAL_CALL OComponentDefinition::disposing()
{
OContentHelper::disposing();
- if ( m_xColumns.is() )
- m_xColumns->disposing();
- m_xColumns.clear();
+ if (m_pColumns)
+ {
+ m_pColumns->disposing();
+ }
m_xColumnPropertyListener->clear();
m_xColumnPropertyListener.clear();
}
@@ -194,7 +195,7 @@ Reference< XNameAccess> OComponentDefinition::getColumns()
::osl::MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(OContentHelper::rBHelper.bDisposed);
- if ( !m_xColumns.is() )
+ if (!m_pColumns)
{
std::vector< OUString> aNames;
@@ -204,10 +205,11 @@ Reference< XNameAccess> OComponentDefinition::getColumns()
for (auto const& definition : rDefinition)
aNames.push_back(definition.first);
- m_xColumns = new OColumns( *this, m_aMutex, true, aNames, this, nullptr, true, false, false );
- m_xColumns->setParent( *this );
+ m_pColumns.reset(new OColumns(*this, m_aMutex, true, aNames, this, nullptr, true, false, false));
+ m_pColumns->setParent(*this);
}
- return m_xColumns.get();
+ // see OCollection::acquire
+ return m_pColumns.get();
}
OColumn* OComponentDefinition::createColumn(const OUString& _rName) const
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
index d43ae556ec17..e71b5fe535a9 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
@@ -84,7 +84,8 @@ class OComponentDefinition :public OContentHelper
,public OComponentDefinition_BASE
,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
{
- rtl::Reference< OColumns > m_xColumns;
+ // no Reference! see OCollection::acquire
+ std::unique_ptr<OColumns> m_pColumns;
rtl::Reference<OColumnPropertyListener> m_xColumnPropertyListener;
bool m_bTable;
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
index ca4ae4253f25..87b1ca9b2447 100644
--- a/dbaccess/source/ui/misc/singledoccontroller.cxx
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -39,10 +39,11 @@ namespace dbaui
// OSingleDocumentController_Data
struct OSingleDocumentController_Data
{
- rtl::Reference< UndoManager > m_xUndoManager;
+ // no Reference! see UndoManager::acquire
+ std::unique_ptr<UndoManager> m_pUndoManager;
OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
- :m_xUndoManager( new UndoManager( i_parent, i_mutex ) )
+ : m_pUndoManager(new UndoManager(i_parent, i_mutex))
{
}
};
@@ -62,7 +63,7 @@ namespace dbaui
{
OSingleDocumentController_Base::disposing();
ClearUndoManager();
- m_pData->m_xUndoManager->disposing();
+ m_pData->m_pUndoManager->disposing();
}
void OSingleDocumentController::ClearUndoManager()
@@ -72,7 +73,7 @@ namespace dbaui
SfxUndoManager& OSingleDocumentController::GetUndoManager() const
{
- return m_pData->m_xUndoManager->GetSfxUndoManager();
+ return m_pData->m_pUndoManager->GetSfxUndoManager();
}
void OSingleDocumentController::addUndoActionAndInvalidate(std::unique_ptr<SfxUndoAction> _pAction)
@@ -90,7 +91,8 @@ namespace dbaui
Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( )
{
- return m_pData->m_xUndoManager.get();
+ // see UndoManager::acquire
+ return m_pData->m_pUndoManager.get();
}
FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const