static/source/embindmaker/embindmaker.cxx |   22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 4b80b643c142d3e5c9e47c091c95155246d6d0e3
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue Jun 18 17:57:25 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Tue Jun 18 20:05:58 2024 +0200

    Embind: Add the lifecylce fix also for attribute getter return values
    
    ...which had accidentally been left out at
    04658a706757dabbedfd87717e6f1f354b4c8961 "Embind: Fix lifecycle of UNO any 
and
    sequence values returned from JS to C++"
    
    Change-Id: I7ec1766850049cb5032020b65ccc171027f739b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169113
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/static/source/embindmaker/embindmaker.cxx 
b/static/source/embindmaker/embindmaker.cxx
index c40b8db6fa24..9727161ff859 100644
--- a/static/source/embindmaker/embindmaker.cxx
+++ b/static/source/embindmaker/embindmaker.cxx
@@ -702,9 +702,25 @@ void dumpWrapperClassMembers(std::ostream& out, 
rtl::Reference<TypeManager> cons
     {
         out << "    ";
         dumpType(out, manager, attr.type);
-        out << " get" << attr.name << "() override { return call<";
-        dumpType(out, manager, attr.type);
-        out << ">(\"get" << attr.name << "\"); }
";
+        out << " get" << attr.name << "() override {";
+        if (attr.type == "any" || attr.type.startsWith("[]"))
+        {
+            out << "
"
+                   "        auto & the_ptr = call<";
+            dumpType(out, manager, attr.type);
+            out << " const &>(\"get" << attr.name
+                << "\");
"
+                   "        auto const the_copy(the_ptr);
"
+                   "        delete &the_ptr;
"
+                   "        return the_copy;
"
+                   "    }
";
+        }
+        else
+        {
+            out << " return call<";
+            dumpType(out, manager, attr.type);
+            out << ">(\"get" << attr.name << "\"); }
";
+        }
         if (!attr.readOnly)
         {
             out << "    void set" << attr.name << "(";

Reply via email to