DocumentEventListener problem

Piet van Oostrum piet at vanoostrum.org
Tue Apr 14 00:49:11 PDT 2015


Michael Stahl wrote:

 > On 12.04.2015 22:53, Piet van Oostrum wrote:
 > > I am trying to program a Global DocumentEventListener in Python.
 > > Then on a certain event (e.g. File Open), I want to analyse/print the paragraph structure of the document.
 > > 
 > > I am running LibreOffice on port 2002. I am using the internal Python from LibreOffice, but I run the script externally, from a Terminal.
 > > 
 > > This is on Mac OS X 10.10, and LO 4.4.2.2.
 > > 
 > > The listener works and gives output until I start an Enumeration, for example enumerating the paragraphs. After the first element LO hangs completely, and the only way out is to kill it. I have tried also with enumerationg the TextFields in the document and it also hangs.
 > > 
 > > So I am wondering if I do something illegal or unsupported, or that I have hit a bug.
 > 
 > looks like a deadlock, quite easy to reproduce, hope Stephan has some
 > time to look at it:

Yes, it seems to lock a mutex without releasing it. Therefore the first paragraph succeeds, but the second blocks because then the mutex is already locked (that's how I estimate the situation).
This also happens with other sets of objects, for example, enumerating the textfields, or accessing the masterfields. The latter doesn't use an enumeration, but it still blocks:

def showmasterfields(doc):
    masters = doc.getTextFieldMasters()
    names = masters.ElementNames
    print("Masters: {}".format(names))
    for name in names:
        print("Get master {}".format(name))
        master = masters.getByName(name)
        print(master)

The strange thing is that it only happens in a listener. When I use it stand-alone it runs without problems, for example:

    doc = Desktop.CurrentComponent
	showportions(doc)
    showfields(doc)
    showmasterfields(doc)

-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]


More information about the LibreOffice mailing list