Tag: cws_src680_dba30
User: fs      
Date: 05/10/13 07:52:22

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

Log:
 RESYNC: (1.62-1.63); FILE MERGED

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.2.3&r2=1.59.2.4
Delta lines:  +12 -20
---------------------
--- datasource.cxx      30 Sep 2005 06:15:47 -0000      1.59.2.3
+++ datasource.cxx      13 Oct 2005 14:52:19 -0000      1.59.2.4
@@ -1202,7 +1202,9 @@
        {
                ResettableMutexGuard _rGuard(m_aMutex);
                
::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-        Reference< css::frame::XStorable> 
xStorable(getModelWithPossibleLeak(),UNO_QUERY);
+
+        SharedModel xModel( impl_getModel( true ) );
+        Reference< css::frame::XStorable> xStorable( xModel, UNO_QUERY );
         if ( xStorable.is() )
             xStorable->store();
 
@@ -1242,28 +1244,14 @@
                m_pImpl->setModified(sal_True);
 }
 // 
-----------------------------------------------------------------------------
-Reference< XModel > ODatabaseSource::getModelWithPossibleLeak()
+ODatabaseSource::SharedModel ODatabaseSource::impl_getModel( bool 
_bTakeOwnershipIfNewlyCreated )
 {
-    Reference< XModel > xModel;
+    SharedModel xModel;
     if ( m_pImpl.is() )
     {
-        xModel = m_pImpl->getModel_noCreate();
+        xModel.reset( m_pImpl->getModel_noCreate(), 
SharedModel::NoTakeOwnership );
         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();
-        }
+            xModel.reset( m_pImpl->createNewModel_deliverOwnership(), 
_bTakeOwnershipIfNewlyCreated ? SharedModel::TakeOwnership : 
SharedModel::NoTakeOwnership );
     }
     return xModel;
 }
@@ -1271,7 +1259,11 @@
 // XDocumentDataSource
 Reference< XOfficeDatabaseDocument > SAL_CALL 
ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
 {
-    return Reference< XOfficeDatabaseDocument >( getModelWithPossibleLeak(), 
UNO_QUERY );
+    return Reference< XOfficeDatabaseDocument >( impl_getModel( false ), 
UNO_QUERY );
+    // by definition, clients of getDatabaseDocument are responsible for the 
model they obtain,
+    // including responsibility for (attempting to) close the model when they 
don't need it anymore.
+    // Thus the "false" parameter in the call to impl_getModel: We don't take 
the ownership
+    // of the model, even if it had to be newly created during this call.
 }
 // 
-----------------------------------------------------------------------------
 //........................................................................




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

Reply via email to