Apache OpenOffice (AOO) Bugzilla – Issue 90531
release database connexion obase ott odt merging
Last modified: 2009-04-23 13:14:23 UTC
i have a macro to merging a.ott with a.odt located in a.odt when i open a.odt, the first fusion work, when i reopen, the merging does not work in fact, the macro get a csv file, create a ods file and odb file to connect a.ott and a.odt with a temporary datasource. the odb file is locked thus macro do not kill this file. what prevents the macro from killing the .odb file. to kill .odb file, i have to kill quickstart.exe and all desktops open. the code of merging is that : Sub Publipostage() Dim sDocumentModele As String, sRepertoireCible As String Dim sNomTable As String, sNomSource As String Dim oMonPublipostage As Object Dim oMyProps() sNomSource = csNomSource sDocumentModele = csFichierLettreType sRepertoireCible = csRepertoireResultat sNomTable = csNomTableDonnees oMonPublipostage = createUnoService("com.sun.star.text.MailMerge") oMonPublipostage.DataSourceName = sNomSource oMonPublipostage.CommandType = com.sun.star.sdb.CommandType.TABLE oMonPublipostage.Command = sNomTable oMonPublipostage.OutputType = com.sun.star.text.MailMergeType.FILE oMonPublipostage..FileNameFromColumn = false oMonPublipostage.DocumentURL = ConvertToURL(sDocumentModele) oMonPublipostage.OutputURL = ConvertToURL(sRepertoireCible) oMonPublipostage.SaveAsSingleFile = True oMonPublipostage.execute(oMyProps()) oMonPublipostage.dispose() end sub i tested with ooo 240 and 30 beta dev m_17 unsuccessfully
According to http://www.openoffice.org/scdocs/ddIssues_EnterModify.html#priority I reduce the prio to 2
Could you please attach - a database document (.odb) with sample data - a text document (.odt) which can be used to do a mail merge based on the database ? This would tremendously ease reproducing the bug case.
Created attachment 54531 [details] ott file exemple
Created attachment 54534 [details] csv file
Created attachment 54535 [details] file odt
Created attachment 54536 [details] file .ott
i confirm that my macro script works for oOo221 but not 240/241 and 30 beta .. you'll find macro in odt courrier.txt tree of located files is : f:\sources\courrier.txt f:\sources\modelesOO\2200-lr.odt f:\sources\modelesOO\2200-lr.ott the first macro function is "main". with data located in courrier.txt, i create a file .ods to populate a file .odb and to over, merge between odb and ott to create a new odt stocked in the folder f:\sources\modelesOO\resultat Thank you very much
will have a deeper look, seems your files allow me to reproduce this, thanks (one note: monDBContext.dispose() is definitely wrong, disposing the DatabaseContext is a bad idea, as all database functionality will cease to function then. Just spare this line in your macro)
fs->os: during running the macro, two connections are opened: One from within the RowSet, which is employed by SwXMailMerge::execute. This connection is freed when the RowSet dies, which is fine. A second connection is created from within SwNewDBMgr::GetConnection, which is called indirectly via SwNewDBMgr::MergeNew, which is called within SwXMailMerge::execute. The second connection is never freed, thus the database document is kept locked. Adding "regression" keyword (since it in fact worked in OOo 2.2.1) and target.
fs->os: In general, I think the SwNewDBMgr's habit of caching connections is broken by design. Keeping a connection longer than you need it is a waste of resources, without giving the user a chance to control the behavior. I would say that every operation at the DB manager should dispose the connection it just created, at least on a high level. That is, some kind of guard { DBClient aGuard( ... ); SwNewDBMgr::doSomething(); SwNewDBMgr::doSomethingElse(); } - where the connection would be freed when the (last) guard dies. This would probably help to get rid of a lot more similar issues (though it's also a bigger change, of course).
Note that another option to fix (only) this particular issue is the following: SwNewDBMgr::MergeNew, called from SwXMailMerge::execute, is given an SwMergeDescriptor, which is allowed to contain an XConnection object. However, this is not used currently. Currently, the connection in the descriptor is set to the value of the ActiveConnection of the MailMerge object. In case this is NULL, it should simply be set to the ActiveConnection of the RowSet (after executing it), and everything should be fine.
I can't see how Prio 2 fits to this http://www.openoffice.org/scdocs/ddIssues_EnterModify.html#priority Adjusted to P3
Created attachment 55151 [details] suggested patch
Intergrated in cws os120
Reassigned for verification
HI->JSK: Please take over, Thanks.
Verified issue on Windows. I had to modify the paths in the macros and to create the file structure. Now the macro runs and ends with a messagebox "Fin de l'operation". I cannot run the macro twice without running into an exception, but it's not the general I/O error that was found in 2.4.1 and 3.0
@coufan, could you please verify your issue in a OOO310m6?
Assuming fixed (appears to work, a stakeholder verificateion would have been better though)