From 836cb73d29dda1d1a90193fa07b1a36b37bf8ec4 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Thu, 23 Feb 2023 12:22:33 +0100 Subject: BindingsGenerator: Release value setting members of dictionary When a constructor has an optional dictionary as argument, and those members are of type new string, make sure that we release_value() setting the dictionary members. --- .../CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Meta') diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index a2c60ffe00..ca044870fc 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -729,9 +729,16 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter } generate_to_cpp(dictionary_generator, member, member_property_value_name, "", member_value_name, interface, member.extended_attributes.contains("LegacyNullToEmptyString"), !member.required, member.default_value); - dictionary_generator.append(R"~~~( + if (optional && interface.extended_attributes.contains("UseNewAKString")) { + dictionary_generator.append(R"~~~( + if (@member_value_name@.has_value()) + @cpp_name@.@member_name@ = @member_value_name@.release_value(); +)~~~"); + } else { + dictionary_generator.append(R"~~~( @cpp_name@.@member_name@ = @member_value_name@; )~~~"); + } if (!member.required && !member.default_value.has_value()) { dictionary_generator.append(R"~~~( } -- cgit v1.2.3