Kaydet (Commit) 66baf6cf authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Noel Grandin

tdf#114596 dbaccess: fix mysterious dataloss bug

OBookmarkContainer actually re-uses the reference count of
ODatabaseSource, so converting ODatabaseSource::m_aBookmark to Reference
created a cycle, which somehow causes the dataloss, because evidently
something as important as storing the data must be done in the
destructor.

(regression from 2660d24a)

(cherry picked from commit 96ae2a33)

tdf#114596 compilerplugins: add exception to [loplugin:refcounting]
(cherry picked from commit e80da608)

Change-Id: I4cad01dc9cdaf405c1eb31d6c0e161eb6712b78f
Reviewed-on: https://gerrit.libreoffice.org/49025Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst eba4d3b5
......@@ -148,6 +148,10 @@ bool containsXInterfaceSubclass(const clang::Type* pType0) {
if (isDerivedFrom(pRecordDecl, [](Decl const * decl) -> bool { return bool(loplugin::DeclCheck(decl).Class("XPropertyList").GlobalNamespace()); })) { // module svx
return false;
}
// tdf#114596
if (isDerivedFrom(pRecordDecl, [](Decl const * decl) -> bool { return bool(loplugin::DeclCheck(decl).Class("OBookmarkContainer").Namespace("dbaccess").GlobalNamespace()); })) { // module dbaccess
return false;
}
}
if (pRecordDecl) {
const ClassTemplateSpecializationDecl* pTemplate = dyn_cast<ClassTemplateSpecializationDecl>(pRecordDecl);
......
......@@ -472,7 +472,7 @@ ODatabaseSource::ODatabaseSource(const ::rtl::Reference<ODatabaseModelImpl>& _pI
:ModelDependentComponent( _pImpl )
,ODatabaseSource_Base( getMutex() )
,OPropertySetHelper( ODatabaseSource_Base::rBHelper )
,m_xBookmarks( new OBookmarkContainer( *this, getMutex() ) )
, m_Bookmarks(*this, getMutex())
,m_aFlushListeners( getMutex() )
{
// some kind of default
......@@ -1153,7 +1153,8 @@ Reference< XConnection > ODatabaseSource::getConnection(const OUString& user, co
Reference< XNameAccess > SAL_CALL ODatabaseSource::getBookmarks( )
{
ModelMethodGuard aGuard( *this );
return static_cast< XNameContainer* >(m_xBookmarks.get());
// tdf#114596 this may look nutty but see OBookmarkContainer::aquire()
return static_cast<XNameContainer*>(&m_Bookmarks);
}
Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( )
......
......@@ -82,7 +82,8 @@ class ODatabaseSource :public ModelDependentComponent // must be first
private:
using ODatabaseSource_Base::rBHelper;
rtl::Reference<OBookmarkContainer> m_xBookmarks;
// note: this thing uses the ref-count of "this", see OBookmarkContainer::acquire!
OBookmarkContainer m_Bookmarks;
::comphelper::OInterfaceContainerHelper2 m_aFlushListeners;
private:
......
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