Board index FlightGear Development Canvas

cannot change immutable string - error when parsing SVG file  Topic is solved

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

cannot change immutable string - error when parsing SVG file

Postby D-ECHO » Wed Jan 20, 2021 6:52 pm

Hi there!

I'm wondering whether anyone else has yet encountered this error:
Code: Select all
28.33 [INFO]:nasal      cannot change immutable string:
 at fgdata/Nasal/canvas/svg.nas, line 428
   28.33 [INFO]:nasal        called from: fgdata/Nasal/canvas/svg.nas, line 748


It is triggered by this nasal command:
Code: Select all
var placards_canvas = canvas.new({
   "name": "C150 Cockpit Placards",
   "size": [1024, 2048],
   "view": [1024, 2048],
   "mipmapping": 1
});
placards_canvas.addPlacement({"node": "placards"});

var svgGroup = placards_canvas.createGroup();

canvas.parsesvg( svgGroup, "Models/placards.svg", {'font-mapper': font_mapper});

with this .svg file: https://www.dropbox.com/s/ogffot46f5uuj ... s.svg?dl=1

I suspect that something in my .svg file is the reason for this, probably a rectangle as this is what line 428 of svg.nas seems to be about, but I'm stuck there. Any pointers are very welcome!

Regards

EDIT: Almost forgot the most important: FGFS is compiled from next a couple of days ago
D-ECHO
 
Posts: 2458
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: cannot change immutable string - error when parsing SVG   

Postby zakalawe » Fri Jan 22, 2021 4:27 pm

It's something related to the <defs> at the root of the SVG: this is apparently used to establish a box clip, but I'm not sure if the svg.nas parser supports it. The rect is referenced by text id=text1021, which has an exceptionally complex style rule.
zakalawe
 
Posts: 1259
Joined: Sat Jul 19, 2008 5:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: cannot change immutable string - error when parsing SVG

Postby D-ECHO » Fri Jan 22, 2021 6:45 pm

Thank you! I don't really know where that came from, but the text was empty and removing the text and <defs> made it work :)
D-ECHO
 
Posts: 2458
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: cannot change immutable string - error when parsing SVG

Postby jsb » Sat Feb 06, 2021 10:45 pm

Thanks for reporting, I may have a look at the parser later.
jsb
 
Posts: 285
Joined: Sat Oct 25, 2014 9:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: cannot change immutable string - error when parsing SVG

Postby jsb » Sun Feb 14, 2021 1:13 pm

<defs><rect> element is not supported by the parser, expected/supported is <defs><mask><rect> and <defs><clipPath><rect>.
I just pushed a fix to FGDATA (next) prevent parser crash on <defs><rect>.
Tested with your file, instead of a nasal crash I see now expected warnings
Code: Select all
 parsesvg: Skipping unknown element in <defs>: <rect> ...


Obviously this still means your file is not fully supported by the parser but at least it won't crash the parser anymore and may or may not show more or less correctly now. ;)
jsb
 
Posts: 285
Joined: Sat Oct 25, 2014 9:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux


Return to Canvas

Who is online

Users browsing this forum: No registered users and 4 guests