File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,10 @@ void ElementSVG::SetInnerRML(const String& content)
120120 if (!source.empty ())
121121 return ;
122122
123+ // We use CreateString instead of std::to_string to avoid having to create an extra std::string and convert it to Rml::String in case clients use
124+ // a non-std string.
123125 if (!HasAttribute (" rmlui-svgdata-id" ))
124- SetAttribute (" rmlui-svgdata-id" , " svgdata:" + std::to_string ( internal_id_counter++));
126+ SetAttribute (" rmlui-svgdata-id" , " svgdata:" + CreateString ( " %lu " , internal_id_counter++));
125127
126128 svg_data = " " + content;
127129 svg_dirty = true ;
Original file line number Diff line number Diff line change @@ -189,14 +189,16 @@ namespace SVG {
189189 return {};
190190 }
191191
192- // We use a reset-release approach here in case clients use a non-std unique_ptr (lunasvg uses std::unique_ptr)
193- doc.svg_document .reset (lunasvg::Document::loadFromData (svg_data).release ());
192+ // We use a reset-release approach here in case clients use a non-std unique_ptr (lunasvg uses std::unique_ptr). We also use
193+ // loadFromData(char*, size_t) instead of loadFromData(std::string) in case clients use a non-std string.
194+ doc.svg_document .reset (lunasvg::Document::loadFromData (svg_data.data (), svg_data.size ()).release ());
194195 }
195196 else
196197 {
197198 RMLUI_SVG_DEBUG_LOG (" Loading SVG document from element %s contents" , source_id.c_str ());
198- // We use a reset-release approach here in case clients use a non-std unique_ptr (lunasvg uses std::unique_ptr)
199- doc.svg_document .reset (lunasvg::Document::loadFromData (source).release ());
199+ // We use a reset-release approach here in case clients use a non-std unique_ptr (lunasvg uses std::unique_ptr). We also use
200+ // loadFromData(char*, size_t) instead of loadFromData(std::string) in case clients use a non-std string.
201+ doc.svg_document .reset (lunasvg::Document::loadFromData (source.data (), source.size ()).release ());
200202 }
201203
202204 if (!doc.svg_document )
You can’t perform that action at this time.
0 commit comments