static/source/unoembindhelpers/PrimaryBindings.cxx |    5 ++++-
 unotest/source/embindtest/embindtest.js            |   17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit c6f39e2deedd93ccf52ca5bb4402cabc3e8bdda7
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Wed May 8 11:08:15 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Thu May 9 18:48:29 2024 +0200

    Embind: Fix uno_Any.get for null interface values
    
    ...which had caused an additional getNull/isNull check for
    a469aea9c0b532d928cd41e389c9c51de1af06f0 "Emscripten: Towards a working C++ 
UNO
    bridge" to fail
    
    Change-Id: Ibe87ca05f795253c9ede8cab6f96da8fe4496f87
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167344
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx 
b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 4972699178c8..9f9a5cf588d5 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -370,7 +370,10 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
                     auto const ifc = *static_cast<css::uno::XInterface* 
const*>(self.getValue());
                     auto const copy = 
std::malloc(sizeof(css::uno::XInterface*));
                     *static_cast<css::uno::XInterface**>(copy) = ifc;
-                    ifc->acquire();
+                    if (ifc != nullptr)
+                    {
+                        ifc->acquire();
+                    }
                     emscripten::internal::WireTypePack argv(std::move(copy));
                     return emscripten::val::take_ownership(
                         _emval_take_value(getTypeId(self.getValueType()), 
argv));
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index 3944f399e3b1..00d9ac68cd3c 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -1027,6 +1027,23 @@ Module.addOnPostRun(function() {
         outparamindex.delete();
         outparam.delete();
     }
+    {
+        const params1 = new Module.uno_Sequence_any(0, 
Module.uno_Sequence.FromSize);
+        const outparamindex = new Module.uno_InOutParam_sequence_short;
+        const outparam = new Module.uno_InOutParam_sequence_any;
+        const ret1 = invoke.invoke('getNull', params1, outparamindex, 
outparam);
+        console.log(ret1.get());
+        const params2 = new Module.uno_Sequence_any([ret1]);
+        const ret2 = invoke.invoke('isNull', params2, outparamindex, outparam);
+        console.log(ret2.get());
+        console.assert(ret2.get());
+        ret1.delete();
+        params1.delete();
+        ret2.delete();
+        params2.delete();
+        outparamindex.delete();
+        outparam.delete();
+    }
 });
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to