User: hr Date: 05/09/23 05:05:27 Modified: /dba/dbaccess/source/core/dataaccess/ datasource.cxx
Log: INTEGRATION: CWS dba201b (1.60.2); FILE MERGED 2005/09/21 07:01:40 oj 1.60.2.4: RESYNC: (1.60-1.62); FILE MERGED 2005/07/21 14:35:03 fs 1.60.2.3: slight syntax changes to the recently introduced SharedUNOComponent for better readability of client code 2005/07/20 10:17:21 fs 1.60.2.2: #i52171# better control over model ownership 2005/07/11 13:37:00 fs 1.60.2.1: merging CWS dba201 into CWS dba201b 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.62&r2=1.63 Delta lines: +37 -45 --------------------- --- datasource.cxx 8 Sep 2005 13:28:51 -0000 1.62 +++ datasource.cxx 23 Sep 2005 12:05:24 -0000 1.63 @@ -1169,7 +1169,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(); @@ -1209,28 +1211,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; } @@ -1238,7 +1226,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]
