Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


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@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.