531 Commits
Author SHA1 Message Date
Andrea Gelmini 850aab7852 Fix typos in code and comments + some reformatting.
Change-Id: I5b6d62104e46c6eb5d142e7e11666806383eed09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210566
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-09-10 15:15:58 +02:00
Michael Weghorn 4a8d42fc6d pyuno: Include Python.h first to avoid _POSIX_C_SOURCE redefinitions
As

    commit a545badd65
    Author: Stephan Bergmann <sbergman@redhat.com>
    Date:   Thu Feb 16 18:15:04 2012 +0100

        Work around macro redefinition warning

already did for pyuno/source/module/pyuno_dlopenwrapper.c ,
also include the <Python.h> header first
in more pyuno source files.

Quoting from the Python/C API reference manual about include
files [1]:

> Note: Since Python may define some pre-processor definitions
> which affect the standard headers on some systems, you must
> include Python.h before any standard headers are included.

This avoids build errors like the following otherwise seen
on Debian testing after a glibc update from 2.42-17 to 2.43-3:

    In file included from /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_struct.cxx:28:
    In file included from /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_impl.hxx:26:
    In file included from /home/michi/development/git/libreoffice/workdir/UnpackedTarball/python3/Include/Python.h:14:
    /home/michi/development/git/libreoffice/workdir/UnpackedTarball/python3/pyconfig.h:1985:9: error: '_POSIX_C_SOURCE' macro redefined [-Werror,-Wmacro-redefined]
     1985 | #define _POSIX_C_SOURCE 200809L
          |         ^
    /usr/include/features.h:319:10: note: previous definition is here
      319 | # define _POSIX_C_SOURCE        202405L
          |          ^

[1] https://docs.python.org/3/c-api/intro.html#include-files

Change-Id: I4ae90cfc9b92b559181d3884cdc8d51ee11f922d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209871
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-26 11:39:00 +02:00
Neil Roberts 97302647ba tdf#173114 pyuno: Don’t require XInvocation2
If an object implements XInvocation then the Invocation service will
directly return the object instead of creating its own invocation
wrapper. In that case the object isn’t guaranteed to also implement
XInvocation2. Previously, this was making pyuno just throw an exception
whenever it encounters one of these objects.

The only case where XInvocation2 is actually used is the implementation
of the __dir__ method. I don’t think this method is used very often so
it’s probably OK to just make it return an empty list if XInvocation2
isn’t supported. That way we can just store a reference to XInvocation
instead of XInvocation2.

This change makes it possible to use objects that implement XInvocation
from Python, for example ooo.vba.excel.Application.

Change-Id: I822c4ffa760f52d6488b9c1009435d059fc19fdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209086
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:43:01 +02:00
Neil Roberts dcc46669fa tdf#173114 pyuno: Handle XInvocation::getIntrospection returning null
Many implementations of XInvocation for internal objects return null for
the getIntrospection method. In pyuno this method is only used in one
place to try and catch the case where the wrapped object is already a
PyUNO adapter. Let’s check for null in that case and assume the object
isn’t an adapter so that it won’t crash when handling objects that
implement XInvocation.

Change-Id: I26576a1a9fec92c679373d9ab47824d992065041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209085
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-13 12:42:53 +02:00
Neil Roberts 935803f2f1 pyuno: Combine two implementations of PyUNO_dir into one
PyUNOStruct_dir is an almost exact copy of PyUNO_dir. This deletes the
first one and makes the struct code instead directly use PyUNO_dir. The
object version has the small advantage that it pre-allocates the Python
list to the right size so the struct code can now take advantage of that
too.

This will make it easier to modify the dir implementation for both use
cases in a later patch.

Change-Id: I7ebe2e6d547fd27c228842effd534e8d71d634ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209084
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:42:45 +02:00
Neil Roberts d2429a3c46 pyuno: Reuse wrapped object when converting Python obj through UNO and back
When any2PyObject is given an interface which is actually an adapter for
a Python object, it now returns the original Python object instead of a
new wrapper for the object. This means that calling methods on the
returned object will be faster because they won’t involve UNO bridging.
It also means that Python implementations of UNO interfaces can detect
when they are given Python objects as a parameter and take advantage of
any internal private data attached to the object.

Change-Id: Ie13d0612f48e70973bd523e68710ec33a7875a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207507
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:09:22 +02:00
Neil Roberts 3223245186 pyuno: Don’t use PyObject_CallOneArg
That function was added in Python 3.9. Even though the LibreOffice
README says the baseline is 3.11, the configure script actually lets you
build with 3.3. I tested with Python 3.5 and it does work apart from
that function call and the fact that desktop-translate.py is using
f-strings. The call to PyObject_CallOneArg was added in the patch below
after the 26.2 branch point so it hasn’t been battle-tested in a release
version yet. Seeing as it’s easy to use an alternative let’s do that in
case someone is using a really old version of Python with pyuno for some
reason.

commit 45d2412c78
Author: Neil Roberts <bpeeluk@yahoo.co.uk>
Date:   Wed Feb 11 16:40:48 2026 +0100

    tdf#171122 pyuno: Add class getter methods for singletons

Change-Id: Ic6f7cf8d0005f59e8cbfd1f9703d393b7e30dabe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206333
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-11 08:23:25 +02:00
AnamayNarkar cecee0d122 pyuno: fix const char* build error in dlopenwrapper.c
Building with clang 21.1.8 and --enable-werror fails because glibc 2.43
adopted the C23 behavior for strrchr(), where it now returns const char*
when its input is const char*. Assigning the result to a plain char*
discards the const qualifier, which clang rejects as an error since the flag is passed.

Change-Id: Ib8eecd603bedb4a69c8f7bd93e49f01e8eba28d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199863
Tested-by: Jenkins
Reviewed-by: Neil Roberts <bpeeluk@yahoo.co.uk>
2026-03-12 04:43:32 +01:00
Caolán McNamara 80d1e26362 cid#1684051 Overflowed integer argument
Change-Id: Ia2e3dc9b80f5bead409701a932b8e0c78baa1524
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201144
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2026-03-06 20:09:18 +01:00
Neil Roberts 45d2412c78 tdf#171122 pyuno: Add class getter methods for singletons
Makes it possible to import the name of a singleton into a Python script
as a class and then retrieve it with a getter method. Eg, instead of:

desktop = ctx.getValueByName(
    "/singletons/com.sun.star.frame.theDesktop")

you can now do:

from com.sun.star.frame import theDesktop
desktop = theDesktop.get(ctx)

Change-Id: I009bd2e890cde52aa6273e462621157fc1f63661
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199219
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:53:28 +01:00
Neil Roberts 346e0f8891 tdf#171122 pyuno: Handle service constructors
This makes it so that services can be imported in Python with code like
this:

from com.sun.star.resource import StringResourceWithLocation

And then an instance of the service can be constructed using any of its
constructors as a class method like this:

res = StringResourceWithLocation.create(ctx, root_url, True, locale,
                                        dlg, '', None)

This has the advantage that the number of arguments can be checked
properly and a more useful error message can be reported if they are not
correct. Because pyuno knows what types the arguments are supposed to
be, it can also do a better job of coercing them to the right ones. For
example in the example above it is possible to pass None for an
interface argument even though that normally represents the void type.

This idea evolved out of the discussion for tdf#169229.

Change-Id: I9b542178f1c101d58dcbbd241d4ecbc9fe38bc2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199104
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:52:55 +01:00
Neil Roberts 507b6c2b90 tdf#169229: pyuno: Allow Any when calling a method
Previously when creating a callable object for an attribute on an
object (ie, a method), it would mark it with a special mode to disallow
passing a pyuno.Any as an argument. There doesn’t seem to be a good
reason to do this and it makes it difficult to use an explicit type when
calling a method that can take an Any. This patch instead just removes
the mode parameter from pyobject2Any entirely.

The example in the bug report is trying to call
createInstanceWithArgumentsAndContext which takes a Sequence of Anys as
an argument. Without this patch it is difficult to pass a null interface
as one of the arguments.

Change-Id: I8756bdc2821ebf247ff67a66f071263ac00e3890
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195452
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-18 10:05:39 +01:00
Stephan Bergmann 82413eb1f9 Improve PyUNO_cmp
...for cases where one operand is a PyUNO Adapter of the other (i.e., one
operand is a Python object that got passed out and back in again, and the other
operand is that same Python object).  This fixes the second "TODO" from
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest".

Change-Id: I0fc938db5c464ed56adee3b428537925fff0fc81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195392
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-11 21:24:20 +01:00
Stephan Bergmann 7bdd020783 Fix any2PyObject mapping of UNO exceptions
That

>             // the exception base functions want to have an "args" tuple,
>             // which contains the message

code is there ever since e80bdbafeb "initial
checkin for the pyuno-0.9.2 release" for reasons that are not clear to me, but
at least in the "TODO" scenarios from 3320b5fe2e
"Add exhaustive testing of PyUNO type mapping based on embindtest" and
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest" (which are hereby fixed), that
PyObject_SetAttrString would cause a Python exception, cf.

> info:pyuno.runtime:1489432:1489432:pyuno/source/module/pyuno_runtime.cxx:533: setting exception args raised Python exception <class 'AttributeError'>: AttributeError('args')

so at least catch that.  (And maybe that code is obsolete anyway it would make
even more sense to drop it altogether.)

Change-Id: Ic651d106f34e0b316cba59ae66d2402b8f86b0f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195340
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-10 07:58:18 +01:00
Stephan Bergmann d89051d184 Don't use OUStringBuffer::apendAscii with UTF-8
(Stumbled over this when while preparing
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest" I accidentally forgot the

> from org.libreoffice.embindtest import Exception

in pyuno/qa/pytests/embindtest.py and thus PythonTest_pyuno_pytests_embindtest
would SIGABRT with

> sal/rtl/strtmpl.hxx:122: auto rtl::str::Copy(sal_Unicode *, const char *, sal_Int32)::(anonymous class)::operator()(char) const: Assertion `rtl::isAscii(static_cast<unsigned char>(c))' failed.

from pyuno::lcl_ExceptionMessage (with reprString being "('error', None,
-123456, 100.5, 'hä')") while trying to report

> uno.com.sun.star.uno.RuntimeException: Couldn't convert ('error', None, -123456, 100.5, 'hä') to a UNO type; caught exception: <class 'AttributeError'>: 'Exception' object has no attribute 'getTypes', traceback follows

.)

Change-Id: I4581061dbfa190266fef98dc670a058d6c98eaaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195304
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2025-12-09 23:56:38 +01:00
Stephan Bergmann 1e2e9a20a4 More exhaustive testing of PyUNO type mapping based on embindtest
...by implementing all the getAny... variants that were left out of
5f05929fd1498e418618d7570192877055de2c80 "Add exhaustive testing of PyUNO type
mapping based on embindtest".

Which revealed that the code in Adapter::invoke (in
pyuno/source/module/pyuno_adapter.cxx) was apparently broken, and would cause
the C++ call in doExecuteTest (in unotest/source/embindtest/embindtest.cxx) of
the Python

>     def getAnyByte(self):
>         return uno.Any('byte', -12)

(in pyuno/qa/pytests/embindtest.py) to fail with a nonsensical

> uno.com.sun.star.uno.RuntimeException: uno.Any instance not accepted during method call, use uno.invoke instead at pyuno/source/module/pyuno_runtime.cxx:785 at stoc/source/invocation_adapterfactory/iafactory.cxx:203

In addition, there's two new places marked with TODO comments:

For one, executing C++

>         bool const ok = test->isAnyException(val);

would cause an odd

> python.bin: Objects/typeobject.c:4745: PyObject *_PyType_Lookup(PyTypeObject *, PyObject *): Assertion `!PyErr_Occurred()' failed.

failure that needs further investigation.

And for another, executing Python

>         return value == self

would always return false.  It appears that PyUNO_cmp (in
pyuno/source/module/pyuno.cxx isn't yet prepared to be called with `that` being
a native Python UNO-implemenation object (`class Test(unohelper.Base, XTest)`)
instead of a proxy for a binary/C++ UNO object.

Change-Id: I0289e1f5ee6dab53b589af783c0c53302989394c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195287
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-09 14:00:54 +01:00
Mike Kaganski b0390a4d1b Drop unohelper.absolutize, and use uno.absolutize to avoid duplication
Change-Id: I9e3b10c5c9b0a0ef1af66c99732bb217d37c3851
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194073
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-11-16 19:10:57 +01:00
Mike Kaganski 641e8b1875 Drop loplugin:stringadd exclusion for pyuno_runtime.cxx
Change-Id: I362f4322fd0948b83272234e4fe52a957aea5f9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191578
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-09-28 19:03:11 +02:00
Caolán McNamara b80cd12449 const up some more pieces
Change-Id: Ib85b8b4b3a2d00e7ef0ecb354fba0b862d60abdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187749
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-07-12 01:16:21 +02:00
Michael Weghorn 07de0b7c91 pyuno: Initialize tp_versions_used for Python >= 3.13
This was added in cpython commit [1]

    commit 992446dd5bd3fff92ea0f8064fb19eebfe105cef
    Author: Mark Shannon <mark@hotpy.org>
    Date:   Mon Feb 5 16:20:54 2024 +0000

        GH-113462: Limit the number of versions that a single class can use. (GH-114900)

, causing an `--enable-werror` build on Debian testing using
system python3-dev 3.13.2-2 to fail like this:

    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_iterator.cxx:185:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
      185 | };
          | ^
    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_iterator.cxx:334:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
      334 | };
          | ^
    2 errors generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:336: /home/michi/development/git/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_iterator.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_callable.cxx:252:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
      252 | };
          | ^
    1 error generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:336: /home/michi/development/git/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_callable.o] Error 1
    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_struct.cxx:377:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
      377 | };
          | ^
    1 error generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:336: /home/michi/development/git/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_struct.o] Error 1
    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno.cxx:1693:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
     1693 | };
          | ^
    1 error generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:336: /home/michi/development/git/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno.o] Error 1
    /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_runtime.cxx:147:1: error: missing field 'tp_versions_used' initializer [-Werror,-Wmissing-field-initializers]
      147 | };
          | ^
    1 error generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:336: /home/michi/development/git/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_runtime.o] Error 1
    make: *** [Makefile:128: pyuno] Error 2

Initialize the member to 0, as e.g. commit [2] does for swig.

For cpython versions this is contained in (from within cpython git repo):

    $ git tag --contains 992446dd5bd3fff92ea0f8064fb19eebfe105cef
    v3.13.0
    v3.13.0a4
    v3.13.0a5
    v3.13.0a6
    v3.13.0b1
    v3.13.0b2
    v3.13.0b3
    v3.13.0b4
    v3.13.0rc1
    v3.13.0rc2
    v3.13.0rc3
    v3.13.1
    v3.13.2
    v3.13.3
    v3.14.0a1
    v3.14.0a2
    v3.14.0a3
    v3.14.0a4
    v3.14.0a5
    v3.14.0a6
    v3.14.0a7

[1] https://github.com/python/cpython/commit/992446dd5bd3fff92ea0f8064fb19eebfe105cef
[2] https://github.com/swig/swig/commit/c3e30c5734a8d9a052b233d2d01e58d409b41df0

Change-Id: I1ad4c511880cf00e4c45b9e835edcd245fe2853c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184198
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-04-15 13:15:42 +02:00
Xisco Fauli c382c5202c tdf#163486: PVS: variable was assigned the same value
Since
commit 2387c2a46e
Author: Matthew J. Francis <mjay.francis@gmail.com>
Date:   Wed Jul 29 15:22:54 2015 +0800

    Give PyUNO structs/exceptions their own separate type

V1048 	The 'me' variable was assigned the same value.

Change-Id: Ia75c524c9cf459ff2961206c9a17dac1de0125a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176530
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2024-11-13 20:12:29 +01:00
Noel Grandin 2cb43c6b88 clang-tidy: performance-unnecessary-copy-initialization in various
Change-Id: Ib7d75d4d8207261898568402e7983e0f11da14bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176417
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-11 21:02:55 +01:00
Noel Grandin 8030c5cfbb loplugin:reftotemp in pyuno..sax
Change-Id: Ia616256e06f64ad3c635ac30abf521e5dab107d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176401
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-11 15:47:38 +01:00
Mike Kaganski 56f3dbffdf Simplify a bit
Change-Id: I618b0f8bcb2e8032ee12367c73e1136685f66b3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176183
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-11-08 05:34:20 +01:00
Noel Grandin 33d4760998 loplugin:passstuffbyref in lotuswordpro..pyuno
Change-Id: I9cd7a98d74b1896951124740b66d873ca41cceae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176197
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-11-07 13:17:27 +01:00
Caolán McNamara 7bbe74b2be cid#1555789 COPY_INSTEAD_OF_MOVE
and

cid#1556865 COPY_INSTEAD_OF_MOVE
cid#1556871 COPY_INSTEAD_OF_MOVE
cid#1556939 COPY_INSTEAD_OF_MOVE
cid#1556951 COPY_INSTEAD_OF_MOVE
cid#1556964 COPY_INSTEAD_OF_MOVE
cid#1556966 COPY_INSTEAD_OF_MOVE
cid#1556968 COPY_INSTEAD_OF_MOVE
cid#1556971 COPY_INSTEAD_OF_MOVE
cid#1556989 COPY_INSTEAD_OF_MOVE
cid#1557001 COPY_INSTEAD_OF_MOVE
cid#1557011 COPY_INSTEAD_OF_MOVE
cid#1557032 COPY_INSTEAD_OF_MOVE
cid#1557038 COPY_INSTEAD_OF_MOVE
cid#1557041 COPY_INSTEAD_OF_MOVE
cid#1557055 COPY_INSTEAD_OF_MOVE
cid#1557056 COPY_INSTEAD_OF_MOVE
cid#1557057 COPY_INSTEAD_OF_MOVE
cid#1557065 COPY_INSTEAD_OF_MOVE
cid#1557068 COPY_INSTEAD_OF_MOVE
cid#1557087 COPY_INSTEAD_OF_MOVE
cid#1557090 COPY_INSTEAD_OF_MOVE
cid#1557093 COPY_INSTEAD_OF_MOVE
cid#1557113 COPY_INSTEAD_OF_MOVE
cid#1557122 COPY_INSTEAD_OF_MOVE
cid#1557126 COPY_INSTEAD_OF_MOVE
cid#1557145 COPY_INSTEAD_OF_MOVE
cid#1557151 COPY_INSTEAD_OF_MOVE
cid#1557152 COPY_INSTEAD_OF_MOVE
cid#1557197 COPY_INSTEAD_OF_MOVE
cid#1557216 COPY_INSTEAD_OF_MOVE
cid#1557245 COPY_INSTEAD_OF_MOVE
cid#1557272 COPY_INSTEAD_OF_MOVE
cid#1557310 COPY_INSTEAD_OF_MOVE
cid#1557314 COPY_INSTEAD_OF_MOVE
cid#1557318 COPY_INSTEAD_OF_MOVE
cid#1557333 COPY_INSTEAD_OF_MOVE
cid#1557340 COPY_INSTEAD_OF_MOVE
cid#1557358 COPY_INSTEAD_OF_MOVE
cid#1557359 COPY_INSTEAD_OF_MOVE
cid#1557365 COPY_INSTEAD_OF_MOVE
cid#1557367 COPY_INSTEAD_OF_MOVE
cid#1557395 COPY_INSTEAD_OF_MOVE
cid#1557418 COPY_INSTEAD_OF_MOVE
cid#1557488 COPY_INSTEAD_OF_MOVE
cid#1557493 COPY_INSTEAD_OF_MOVE
cid#1557506 COPY_INSTEAD_OF_MOVE
cid#1557514 COPY_INSTEAD_OF_MOVE
cid#1557528 COPY_INSTEAD_OF_MOVE
cid#1557534 COPY_INSTEAD_OF_MOVE
cid#1557537 COPY_INSTEAD_OF_MOVE
cid#1557562 COPY_INSTEAD_OF_MOVE
cid#1557563 COPY_INSTEAD_OF_MOVE
cid#1557592 COPY_INSTEAD_OF_MOVE
cid#1557608 COPY_INSTEAD_OF_MOVE
cid#1557615 COPY_INSTEAD_OF_MOVE
cid#1557619 COPY_INSTEAD_OF_MOVE
cid#1557637 COPY_INSTEAD_OF_MOVE
cid#1557648 COPY_INSTEAD_OF_MOVE
cid#1557712 COPY_INSTEAD_OF_MOVE
cid#1557750 COPY_INSTEAD_OF_MOVE
cid#1557762 COPY_INSTEAD_OF_MOVE
cid#1557765 COPY_INSTEAD_OF_MOVE

Change-Id: I10db1910627e04a26e25836c05ad5c2707abd18b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175696
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-10-27 20:19:12 +01:00
Caolán McNamara 6f1508f4de cid#1555767 COPY_INSTEAD_OF_MOVE
and

cid#1555770 COPY_INSTEAD_OF_MOVE
cid#1555788 COPY_INSTEAD_OF_MOVE
cid#1555789 COPY_INSTEAD_OF_MOVE
cid#1555798 COPY_INSTEAD_OF_MOVE
cid#1555816 COPY_INSTEAD_OF_MOVE
cid#1555822 COPY_INSTEAD_OF_MOVE
cid#1555835 COPY_INSTEAD_OF_MOVE
cid#1555845 COPY_INSTEAD_OF_MOVE
cid#1555859 COPY_INSTEAD_OF_MOVE
cid#1555864 COPY_INSTEAD_OF_MOVE
cid#1555868 COPY_INSTEAD_OF_MOVE
cid#1555892 COPY_INSTEAD_OF_MOVE
cid#1555896 COPY_INSTEAD_OF_MOVE
cid#1555921 COPY_INSTEAD_OF_MOVE
cid#1555932 COPY_INSTEAD_OF_MOVE
cid#1555935 COPY_INSTEAD_OF_MOVE
cid#1555944 COPY_INSTEAD_OF_MOVE
cid#1555952 COPY_INSTEAD_OF_MOVE
cid#1555985 COPY_INSTEAD_OF_MOVE
cid#1556024 COPY_INSTEAD_OF_MOVE
cid#1556038 COPY_INSTEAD_OF_MOVE
cid#1556042 COPY_INSTEAD_OF_MOVE
cid#1556044 COPY_INSTEAD_OF_MOVE
cid#1556060 COPY_INSTEAD_OF_MOVE
cid#1556083 COPY_INSTEAD_OF_MOVE
cid#1556085 COPY_INSTEAD_OF_MOVE
cid#1556090 COPY_INSTEAD_OF_MOVE
cid#1556136 COPY_INSTEAD_OF_MOVE
cid#1556157 COPY_INSTEAD_OF_MOVE
cid#1556159 COPY_INSTEAD_OF_MOVE
cid#1556172 COPY_INSTEAD_OF_MOVE
cid#1556179 COPY_INSTEAD_OF_MOVE
cid#1556187 COPY_INSTEAD_OF_MOVE
cid#1556255 COPY_INSTEAD_OF_MOVE
cid#1556256 COPY_INSTEAD_OF_MOVE
cid#1556266 COPY_INSTEAD_OF_MOVE
cid#1556275 COPY_INSTEAD_OF_MOVE
cid#1556290 COPY_INSTEAD_OF_MOVE
cid#1556294 COPY_INSTEAD_OF_MOVE
cid#1556301 COPY_INSTEAD_OF_MOVE
cid#1556311 COPY_INSTEAD_OF_MOVE
cid#1556318 COPY_INSTEAD_OF_MOVE
cid#1556326 COPY_INSTEAD_OF_MOVE
cid#1556369 COPY_INSTEAD_OF_MOVE
cid#1556374 COPY_INSTEAD_OF_MOVE
cid#1556387 COPY_INSTEAD_OF_MOVE
cid#1556388 COPY_INSTEAD_OF_MOVE
cid#1556417 COPY_INSTEAD_OF_MOVE
cid#1556425 COPY_INSTEAD_OF_MOVE
cid#1556435 COPY_INSTEAD_OF_MOVE
cid#1556495 COPY_INSTEAD_OF_MOVE
cid#1556497 COPY_INSTEAD_OF_MOVE
cid#1556501 COPY_INSTEAD_OF_MOVE
cid#1556503 COPY_INSTEAD_OF_MOVE
cid#1556520 COPY_INSTEAD_OF_MOVE
cid#1556523 COPY_INSTEAD_OF_MOVE
cid#1556562 COPY_INSTEAD_OF_MOVE
cid#1556573 COPY_INSTEAD_OF_MOVE
cid#1556576 COPY_INSTEAD_OF_MOVE
cid#1556598 COPY_INSTEAD_OF_MOVE
cid#1556615 COPY_INSTEAD_OF_MOVE
cid#1556626 COPY_INSTEAD_OF_MOVE
cid#1556671 COPY_INSTEAD_OF_MOVE
cid#1556689 COPY_INSTEAD_OF_MOVE
cid#1556701 COPY_INSTEAD_OF_MOVE
cid#1556713 COPY_INSTEAD_OF_MOVE
cid#1556758 COPY_INSTEAD_OF_MOVE
cid#1556759 COPY_INSTEAD_OF_MOVE
cid#1556788 COPY_INSTEAD_OF_MOVE
cid#1556811 COPY_INSTEAD_OF_MOVE
cid#1556821 COPY_INSTEAD_OF_MOVE
cid#1556824 COPY_INSTEAD_OF_MOVE
cid#1556825 COPY_INSTEAD_OF_MOVE
cid#1556862 COPY_INSTEAD_OF_MOVE

Change-Id: I4925a79688a983bb07252600430039ec0bcb75b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175678
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-10-26 19:25:03 +02:00
Stephan Bergmann d02310ba14 Remaining GCC -Wcast-function-type issues
As Clang supports that warning now too, lots of occurrences have meanwhile been
cleaned up for good (0c29c417ef "Avoid
-Werror,-Wcast-function-type-mismatch", 1344e6261a
"Avoid -Werror,-Wcast-function-type-mismatch",
85a2bb9f52 "Avoid
-Werror,-Wcast-function-type-mismatch", etc.), so
ce99754e9b "Globally disable -Wcast-function-type
new with upcoming GCC 8" in solenv/gbuild/platform/com_GCC_defs.mk should no
longer be necessary.

One remaining issue I encountered was dae7304df6
"Silence Clang 19 trunk -Werror,-Wcast-function-type-mismatch", where GCC needs
a different way for silencing the warnings in pyuno/source/module/ than had been
used there for Clang.

Change-Id: I5d0404b957d798114051209c31e022a898cf91f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173623
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-09-19 07:35:49 +02:00
Michael Stahl 8ed755cfb0 pyuno,unotest,xmlsecurity: copy GPG test files for UITtest
The problem was that running UITest_xmlsecurity_gpg changed the files in
test/signing-keys/ ... prevent that by copying the directory in that
test, which is more complicated than initially expected.

Change-Id: Ie3be922e0b2e9dae49f9a70e35ad5270c90b4fc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171322
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Jenkins
2024-08-01 11:18:30 +02:00
Gabor Kelemen e1a351ca19 Remove now unneeded osl/diagnose.h
followup to commit 57c228803e

Change-Id: Iebfb23bb65e2bf898bf27f367cc9641f47a14cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167998
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
2024-07-20 10:20:31 +02:00
Caolán McNamara e68f28ec9f cid#1607892 COPY_INSTEAD_OF_MOVE
and

cid#1607910 COPY_INSTEAD_OF_MOVE
cid#1607818 COPY_INSTEAD_OF_MOVE
cid#1557402 COPY_INSTEAD_OF_MOVE
cid#1556530 COPY_INSTEAD_OF_MOVE
cid#1557396 COPY_INSTEAD_OF_MOVE
cid#1556522 COPY_INSTEAD_OF_MOVE
cid#1555628 COPY_INSTEAD_OF_MOVE
cid#1554705 COPY_INSTEAD_OF_MOVE

Change-Id: Iae3fbf4a04bf3714f416995640b9d70fe204cf73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170321
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-11 09:26:28 +02:00
Xisco Fauli 4a3706db4f pyuno: fix deprecated warnings
* Replace PyUnicode_FromUnicode(str, len) with PyUnicode_FromWideChar(str, len)
* Replace PyUnicode_AS_UNICODE(PyObject) with PyUnicode_AsWideCharString(PyObject, size)

Change-Id: I1d8b46059d72f4de261d99393e1681f1e41eafdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169625
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-07-05 23:14:52 +02:00
Noel Grandin ed699baa92 workaround clang segfault on macos-intel
Change-Id: Icfced4a990e2d02995bff4078f14b8ee26e9cca3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167497
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-11 14:50:28 +02:00
Noel Grandin 79f4f724b9 loplugin:ostr in pyuno
Change-Id: I54555110b5c66ea92f2675edc50dccd252558e28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167435
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-10 13:16:45 +02:00
Stephan Bergmann dae7304df6 Silence Clang 19 trunk -Werror,-Wcast-function-type-mismatch
Change-Id: Icd0af828e47c770ca8964656188d0d722a7f1ddc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165250
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-24 23:13:48 +01:00
Justin Luth daa04d405a allow build with python 3.12.0: initialize new tp_watched
This fixes the build failure after I updated Ubuntu 24.04 (alpha),
which upgraded python 3.11.7 to python 3.12.0, causing the error:

libreoffice/pyuno/source/module/pyuno_callable.cxx:249:1:
error: missing initializer for member ‘_typeobject::tp_watched’
[-Werror=missing-field-initializers]
...

I gleaned this information from a July 2023 commit for
https://github.com/xbmc/xbmc/issues/23503

tp_watched was added in upstream commit python/cpython@82ccbf6
https://github.com/python/cpython/commit/82ccbf69a842db25d8117f1c41b47aa5b4ed96ab

This change first appeared in Python v3.12.0a1

Change-Id: If82ff1eb47d66d2669d90d6e00e0feff3c55b5ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164775
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-13 17:45:49 +01:00
Aron Budea 6efe49e729 pyuno: Use expected return value (-1) on failure
Both PyObject_SetAttr and PyObject_SetItem are expected to:

Raise an exception and return -1 on failure; return 0 on success.
https://docs.python.org/3/c-api/object.html

Change-Id: Id1f6129e91e9da2f5d3bc1858422eeee4c3393d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163418
Tested-by: Jenkins
Reviewed-by: Aron Budea <aron.budea@collabora.com>
2024-02-15 12:49:31 +01:00
Mike Kaganski 0fa827dbb2 Drop std::as_const from css::uno::Sequence iterations
Obsoleted by commit 2484de6728 (Remove
non-const Sequence::begin()/end() in internal code, 2021-10-15) and
commit fb3c04bd19 (Drop non-const
Sequence::operator[] in internal code, 2021-11-05).

Change-Id: Idbafef5d34c0d4771cbbf75b9db9712e504164cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162640
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-27 12:43:48 +01:00
Stephan Bergmann 115e7a00c3 Extended loplugin:ostr: pyuno
Change-Id: Ie8ec1e8b3debd1501b16d40567a063390749a19b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159683
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-11-19 20:39:16 +01:00
sahil c0e687edf4 tdf#130924 replace '*printf' with 'SAL_*' logging macros in pyuno
Change-Id: I2c491629f52fe0b90517c563f221d7d0345b6ee9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156452
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-10-23 16:54:59 +02:00
Mike Kaganski 176e8cf09a Use exception ctors, instead of setting members later
Avoids overwriting source location in message

Change-Id: Ia0290c7dd1ab3ea1357712a27ecab75c7b583dd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157893
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-10-14 15:37:17 +02:00
Caolán McNamara 86160b081b cid#1546834 Unchecked return value
Change-Id: Id2c54c61d3d44611ab02db81b8e64cedb0010ba7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157398
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-09-29 14:14:13 +02:00
Noel Grandin 7f91e4a982 loplugin:stringadd in oox..pyuno
after my patch to merge the bufferadd loplugin into stringadd

Change-Id: I5fdc0a33923fe00e7b588f4576607515a93e5c13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149579
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-27 11:04:46 +00:00
buldi 8ca611b212 tdf#143148 Use pragma once instead of include guards
Change-Id: I5a88b699425a37b914a71400e918965a9f6116eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146730
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-02-13 11:26:27 +00:00
Noel Grandin 1743d74e87 clang-tidy modernize-pass-by-value in various
Change-Id: Ie091b22bd77d4e1fbff46545bc86c12f1dbafcfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138171
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-13 19:11:49 +02:00
Noel Grandin 4c909d1466 loplugin:passstuffbyref
Change-Id: Ib2b2650da7abc9260897f9b5aad619a0ea6ae941
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138052
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-10 08:07:03 +02:00
Niko Fink 1052ec9cff tdf#133123: fix crash when importing defusedxml.ElementTree after pyuno
Change-Id: I89ac6108c679504c81dd9a439a4fb02e9e1adc07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138007
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-09 11:55:38 +02:00
Noel Grandin e7903c01b1 elide some makeStringAndClear() calls
Change-Id: I3b80d0f5b6d39c071242bc6ccc1e4333886c835d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137309
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-22 11:14:37 +02:00
Stephan Bergmann 51c9862303 Just use Any ctor instead of makeAny in pyuno
Change-Id: I53eb836c64e8e4a354c5c895bc7f16b168bd4cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133793
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-04 08:41:43 +02:00
Stephan Bergmann b3b18ed165 Don't make UNO calls from PyThreadAttached regions (i.e., with the GIL locked)
...which caused e.g. UITest_writer_tests3 to occasionally hang with the
python.bin process thread 1 at

>   File "sw/qa/uitest/writer_tests3/insertPageFooter.py", line 30, in delete_footer
[...]

i.e.,

> #4  ___pthread_cond_wait at /usr/src/debug/glibc-2.35-4.fc36.x86_64/nptl/pthread_cond_wait.c:618
> #5  0x00007ff9d6ad9c43 in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:72
> #6  0x00007ff9d6ae8e79 in cppu_threadpool::ThreadPool::enter(rtl::ByteSequence const&, void const*) at cppu/source/threadpool/threadpool.cxx:303
> #7  0x00007ff9d6ae9278 in uno_threadpool_enter(uno_ThreadPool, void**) at cppu/source/threadpool/threadpool.cxx:407
> #8  0x00007ff9c7d016eb in binaryurp::Bridge::makeCall(rtl::OUString const&, com::sun::star::uno::TypeDescription const&, bool, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >&&, binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) at binaryurp/source/bridge.cxx:604
> #9  0x00007ff9c7d322fc in binaryurp::Proxy::do_dispatch_throw(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:168
> #10 0x00007ff9c7d338cb in binaryurp::Proxy::do_dispatch(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:101
> #11 0x00007ff9d63222e0 in cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy*, typelib_TypeDescription const*, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:191
> #12 0x00007ff9d6322b59 in cpp_vtable_call(sal_Int32, sal_Int32, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:389
> #13 0x00007ff9d63336ca in privateSnippetExecutor at instdir/program/libgcc3_uno.so
> #14 0x00007ff9d6241f38 in (anonymous namespace)::ImplIntrospectionAccess::hasByName(rtl::OUString const&) at stoc/source/inspect/introspection.cxx:1114
> #15 0x00007ff9d6b856b2 in pyuno::PyUNO_getattr(PyObject*, char*) at pyuno/source/module/pyuno.cxx:1392
[...]

doing a remote call to soffice.bin with GIL locked, and thread 4 at

> #6  0x00007ff9e51efa28 in take_gil at workdir/UnpackedTarball/python3/Python/ceval_gil.h:207
> #7  0x00007ff9e51f00d3 in PyEval_AcquireThread at workdir/UnpackedTarball/python3/Python/ceval.c:316
> #8  0x00007ff9d6b9b1e8 in pyuno::Adapter::invoke(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Sequence<short>&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) at pyuno/source/module/pyuno_adapter.cxx:181
> #9  0x00007ff9d632b3e4 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77
> #10 0x00007ff9d632a4f1 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233
> #11 0x00007ff9d632a9e6 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413
> #12 0x00007ff9d621384a in stoc_invadp::(anonymous namespace)::AdapterImpl::invoke at stoc/source/invocation_adapterfactory/iafactory.cxx:457
> #13 stoc_invadp::adapter_dispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at stoc/source/invocation_adapterfactory/iafactory.cxx:605
> #14 0x00007ff9c7d1a7db in binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const at include/typelib/typedescription.hxx:155
> #15 0x00007ff9c7d1d65f in binaryurp::IncomingRequest::execute() const at binaryurp/source/incomingrequest.cxx:78
> #16 0x00007ff9c7d33ad3 in binaryurp::(anonymous namespace)::request(void*) at ~/gcc/trunk/inst/include/c++/12.0.1/bits/unique_ptr.h:172
> #17 0x00007ff9d6ad9e1b in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:100
> #18 0x00007ff9d6adbb80 in cppu_threadpool::ORequestThread::run() at cppu/source/threadpool/thread.cxx:164
[...]

processing an unrelated incoming call from soffice.bin and blocked trying to
lock the GIL.  (The reason that thread 1 doesn't make progress is that the
soffice.bin process is also blocking with thread 6 at

> #8  osl::Guard<comphelper::SolarMutex>::Guard(comphelper::SolarMutex&) at include/osl/mutex.hxx:142
> #9  SolarMutexGuard::SolarMutexGuard() at include/vcl/svapp.hxx:1368
> #10 sw::(anonymous namespace)::XStyleFamily::hasByName(rtl::OUString const&) at sw/source/core/unocore/unostyle.cxx:923
> #11 0x00007f089d3d53e4 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77
> #12 0x00007f089d3d44f1 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233
> #13 0x00007f089d3d49e6 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413
> #14 0x00007f089c1be7db in binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const at include/typelib/typedescription.hxx:155
> #15 0x00007f089c1c165f in binaryurp::IncomingRequest::execute() const at binaryurp/source/incomingrequest.cxx:78
> #16 0x00007f089c1d7ad3 in binaryurp::(anonymous namespace)::request(void*) at ~/gcc/trunk/inst/include/c++/12.0.1/bits/unique_ptr.h:172
> #17 0x00007f08a18ade1b in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:100
> #18 0x00007f08a18afb80 in cppu_threadpool::ORequestThread::run() at cppu/source/threadpool/thread.cxx:164
[...]

processing the incoming call from python.bin thread 1 and blocked trying to lock
the SolarMutex, while thread 1 at

> #4  ___pthread_cond_wait at /usr/src/debug/glibc-2.35-4.fc36.x86_64/nptl/pthread_cond_wait.c:618
> #5  0x00007f08a18adc43 in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:72
> #6  0x00007f08a18bce79 in cppu_threadpool::ThreadPool::enter(rtl::ByteSequence const&, void const*) at cppu/source/threadpool/threadpool.cxx:303
> #7  0x00007f08a18bd278 in uno_threadpool_enter(uno_ThreadPool, void**) at cppu/source/threadpool/threadpool.cxx:407
> #8  0x00007f089c1a56eb in binaryurp::Bridge::makeCall(rtl::OUString const&, com::sun::star::uno::TypeDescription const&, bool, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >&&, binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) at binaryurp/source/bridge.cxx:604
> #9  0x00007f089c1d62fc in binaryurp::Proxy::do_dispatch_throw(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:168
> #10 0x00007f089c1d78cb in binaryurp::Proxy::do_dispatch(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:101
> #11 0x00007f089d3cc2e0 in cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy*, typelib_TypeDescription const*, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:191
> #12 0x00007f089d3ccb59 in cpp_vtable_call(sal_Int32, sal_Int32, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:389
> #13 0x00007f089d3dd6ca in privateSnippetExecutor at instdir/program/libgcc3_uno.so
> #14 0x00007f08a6b5d170 in operator() at sfx2/source/notify/globalevents.cxx:491
> #15 comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::forEach<(anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(const com::sun::star::document::DocumentEvent&)::<lambda(const com::sun::star::uno::Reference<com::sun::star::document::XDocumentEventListener>&)> > at include/comphelper/interfacecontainer4.hxx:285
> #16 at sfx2/source/notify/globalevents.cxx:488
> #17 0x00007f08a6b04c8b in (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>::operator() (listener=Python Exception <class 'gdb.error'>: Dwarf Error: Cannot find DIE at 0x0 referenced in module instdir/program/libmergedlo.so
> #18 comphelper::OInterfaceContainerHelper2::forEach<com::sun::star::document::XDocumentEventListener, at include/comphelper/interfacecontainer2.hxx:271
> #19 SfxBaseModel::postEvent_Impl(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::frame::XController2> const&, com::sun::star::uno::Any const&) at sfx2/source/doc/sfxbasemodel.cxx:3253
> #20 0x00007f08a6b066fe in SfxBaseModel::Notify(SfxBroadcaster&, SfxHint const&) at sfx2/source/doc/sfxbasemodel.cxx:2902
> #21 0x00007f08a6f15def in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:39
> #22 0x00007f087d640650 in SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*) at sw/source/core/layout/layact.cxx:2389
> #23 0x00007f087dc0832b in SwViewShell::LayoutIdle() at sw/source/core/view/viewsh.cxx:821
> #24 0x00007f087d2ba194 in sw::DocumentTimerManager::DoIdleJobs(Timer*) at sw/source/core/inc/rootfrm.hxx:206
> #25 0x00007f08a89fbd26 in Scheduler::CallbackTaskScheduling() at vcl/source/app/scheduler.cxx:472
> #26 0x00007f08a8ca8780 in SalTimer::CallCallback() at vcl/inc/saltimer.hxx:54
> #27 SvpSalInstance::CheckTimeout(bool) at vcl/headless/svpinst.cxx:212
> #28 0x00007f08a8ca99bd in SvpSalInstance::ImplYield(bool, bool) at vcl/headless/svpinst.cxx:452
> #29 0x00007f08a8ca9db1 in SvpSalInstance::DoYield(bool, bool) at vcl/headless/svpinst.cxx:524
> #30 0x00007f08a8a27d4c in ImplYield(bool, bool) at vcl/source/app/svapp.cxx:474
> #31 0x00007f08a8a28445 in Application::Execute() at vcl/source/app/svapp.cxx:452
[...]

is doing the remote call to python.bin thread 4 with the SolarMutex erroneously
locked.  But lets concentrate on just fixing the python.bin deadlock in this
commit.)

The PyThreadDetach antiguard just covering the xInvocation->getValue call in the
"or a property" case had been added with
e0a1cd4dc7 "fixed a deadlock", presumably without
taking into account that the xInvocation->hasMethod/hasProperty calls are
equally problematic.

Change-Id: I2483949df8213c3397a674be190224ee58c95c02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132428
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-04-01 16:56:58 +02:00