User: obo     
Date: 05/07/08 03:36:41

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

Log:
 INTEGRATION: CWS dba20blocker (1.59.58); FILE MERGED
 2005/06/24 09:13:27 fs 1.59.58.2: assertion spelling
 2005/06/23 13:56:42 fs 1.59.58.1: copying fix for #i50905# into this CWS

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.60
Delta lines:  +34 -8
--------------------
--- datasource.cxx      23 Mar 2005 09:46:37 -0000      1.59
+++ datasource.cxx      8 Jul 2005 10:36:39 -0000       1.60
@@ -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! 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 );
 }
 // 
-----------------------------------------------------------------------------
 //........................................................................




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

Reply via email to