Index: dbaccess/source/core/dataaccess/databasedocument.cxx =================================================================== RCS file: /cvs/dba/dbaccess/source/core/dataaccess/databasedocument.cxx,v --- dbaccess/source/core/dataaccess/databasedocument.cxx 16 Apr 2007 16:23:47 -0000 1.32 +++ dbaccess/source/core/dataaccess/databasedocument.cxx 28 Jun 2007 04:52:04 -0000 @@ -1087,6 +1087,31 @@ // normally, nobody should explicitly dispose, but only XCloseable::close the document. And upon // closing, our controllers are closed, too + // just in case... + if(!m_pImpl->m_aControllers.empty()) + { + // We can't use an iterator here, since we are erasing from the + // vector as we go through it. + sal_Int32 aSize = m_pImpl->m_aControllers.size(); + sal_Int32 aIndex; + for(aIndex = 0; aIndex < aSize; aIndex++) + { + Reference< XController > aController = m_pImpl->m_aControllers.front(); + + // If the Controller exists, disconnect it, otherwise just erase + // it from the list. + if(aController.is()) + { + disconnectController(aController); + } + else + { + ControllerArray::iterator aIter = m_pImpl->m_aControllers.begin(); + m_pImpl->m_aControllers.erase(aIter); + } + } + } + Reference< XModel > xHoldAlive( this ); { {