Tag: cws_src680_c03v1
User: fs      
Date: 05/06/21 02:57:13

Modified:
 /dba/dbaccess/source/core/dataaccess/
  datasource.cxx, datasource.hxx

Log:
 #i50905# getModelWithPossibleLeak - method obtaining a model where the 
ownership is not clearly defined

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: datasource.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.cxx?r1=1.59&r2=1.59.54.1
Delta lines:  +37 -11
---------------------
--- datasource.cxx      23 Mar 2005 09:46:37 -0000      1.59
+++ datasource.cxx      21 Jun 2005 09:57:10 -0000      1.59.54.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.cxx,v $
  *
- *  $Revision: 1.59 $
+ *  $Revision: 1.59.54.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/23 09:46:37 $
+ *  last change: $Author: fs $ $Date: 2005/06/21 09:57:10 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -125,9 +125,6 @@
 #ifndef _COMPHELPER_INTERACTION_HXX_
 #include <comphelper/interaction.hxx>
 #endif
-#ifndef DBA_COREDATAACCESS_COMMITLISTENER_HXX
-#include "commitlistener.hxx"
-#endif
 #ifndef _DBA_CORE_CONNECTION_HXX_
 #include "connection.hxx"
 #endif
@@ -143,6 +140,9 @@
 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTEDOBJECT_HPP_
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTSUBSTORAGESUPPLIER_HPP_
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#endif
 
 #include <com/sun/star/document/XEventBroadcaster.hpp>
 #include <com/sun/star/view/XPrintable.hpp>
@@ -737,8 +737,8 @@
                                aDriverInfo[nCount].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
                                aDriverInfo[nCount++].Value <<= 
m_pImpl->getURL();
                                aDriverInfo[nCount].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage"));
-                               Reference<css::embed::XTransactionListener> 
xEvt(m_pImpl->m_xModel,UNO_QUERY);
-                               aDriverInfo[nCount++].Value <<= 
m_pImpl->getStorage(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")),xEvt,ElementModes::READWRITE);
+                Reference< css::document::XDocumentSubStorageSupplier> 
xDocSup( m_pImpl->getDocumentSubStorageSupplier() );
+                               aDriverInfo[nCount++].Value <<= 
xDocSup->getDocumentSubStorage(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")),ElementModes::READWRITE);
                        }
                        if (nAdditionalArgs)
                                xReturn = 
xManager->getConnectionWithInfo(m_pImpl->m_sConnectURL, 
::comphelper::concatSequences(aUserPwd,aDriverInfo));
@@ -1195,7 +1195,7 @@
        {
                ResettableMutexGuard _rGuard(m_aMutex);
                
::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-        Reference< css::frame::XStorable> 
xStorable(m_pImpl->getModel(),UNO_QUERY);
+        Reference< css::frame::XStorable> 
xStorable(getModelWithPossibleLeak(),UNO_QUERY);
         if ( xStorable.is() )
             xStorable->store();
                
@@ -1235,10 +1235,36 @@
                m_pImpl->setModified(sal_True);
 }
 // 
-----------------------------------------------------------------------------
+Reference< XModel > ODatabaseSource::getModelWithPossibleLeak()
+{
+    Reference< XModel > xModel;
+    if ( m_pImpl.is() )
+    {
+        xModel = m_pImpl->getModel_noCreate();
+        if ( !xModel.is() )
+        {
+            // In the course of #i50905#, the ownership of a XModel instance 
was more clearly
+            // defined and respected throughout all involved implementations. 
This place
+            // here is the last one where a fix wasn't easily possible within 
the restrictions
+            // which applied to the fix (time frame, risk)
+            //
+            // There's a pretty large comment in 
ODatabaseDocument::disconnectController
+            // explaining how this dilemma could be solved (which in fact 
suggests to
+            // get completely rid of the "sole ownership" concept, and replace 
it with
+            // shared ownership, and vetoable closing).
+            //
+            // #i50905# / 2005-06-20 / [EMAIL PROTECTED]
+            DBG_ERROR( "ODatabaseSource::::getModelWithPossibleLeak: creating 
a model instance with undefined ownership! Most probably a resource leak!" );
+            xModel = m_pImpl->createNewModel_deliverOwnership();
+        }
+    }
+    return xModel;
+}
+// 
-----------------------------------------------------------------------------
 // XDocumentDataSource
-Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument > SAL_CALL 
ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
+Reference< XOfficeDatabaseDocument > SAL_CALL 
ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
 {
-       return m_pImpl.is() ? Reference< 
::com::sun::star::sdb::XOfficeDatabaseDocument >(m_pImpl->getModel(),UNO_QUERY) 
: Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >();
+    return Reference< XOfficeDatabaseDocument >( getModelWithPossibleLeak(), 
UNO_QUERY );
 }
 // 
-----------------------------------------------------------------------------
 //........................................................................

File [changed]: datasource.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.hxx?r1=1.29&r2=1.29.62.1
Delta lines:  +6 -3
-------------------
--- datasource.hxx      10 Mar 2005 16:34:36 -0000      1.29
+++ datasource.hxx      21 Jun 2005 09:57:11 -0000      1.29.62.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.hxx,v $
  *
- *  $Revision: 1.29 $
+ *  $Revision: 1.29.62.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:34:36 $
+ *  last change: $Author: fs $ $Date: 2005/06/21 09:57:11 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -316,6 +316,9 @@
                const rtl::OUString& user, const rtl::OUString& password
                );
 
+    /// see the implementation for an explanation for the method's name ...
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+        getModelWithPossibleLeak();
 
 // other stuff
        void    flushTables();




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to