EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
327 stars 96 forks source link

Image Editor in Demo throws exception when svg is invalid #110

Closed luebbe closed 4 years ago

luebbe commented 4 years ago

Steps to reproduce:

The editor and preview update fine, if correct svg content is pasted into the edit box.

It would be nice if either the exception would be handled gracefully.

Serge-Girard commented 4 years ago

Hi, First I want to applause this great job. I ran in the same problem luebbe attempting to load the European flag (https://upload.wikimedia.org/wikipedia/commons/b/b7/Flag_of_Europe.svg) Worth it was FMX flavor and IDE freeze :-(

Anyway all the others flags I had in my test repertory passed the test : new salve of applause ;-) As an aside, I am jealous, I had on my side a sort of ImageLoadFromSVGFile FMX component using the existing Graphics.TPath and my stars can't be filled.

carloBarazzetta commented 4 years ago

To fix this problem I need to remove:

except fSource := ''; end;

from TD2DSVG.LoadFromSource;

@pyscripter it's necessary maintain this code at this level? I prefer that the component raises an exception if the SVG Text is wrong... so the ComponentEditor can show it on an "error panel", and preserve the text...

pyscripter commented 4 years ago

@carloBarazzetta TD2DSVG.LoadFromSource replicates what TSVG.LoadFromText is doing. Feel free to change it, however if you change one you should be changing both.

@Serge-Girard The European flag loads and renders correctly here with both factories. Are you using the latest version?

carloBarazzetta commented 4 years ago

@carloBarazzetta TD2DSVG.LoadFromSource replicates what TSVG.LoadFromText is doing. Feel free to change it, however if you change one you should be changing both.

Yes, it's the same logic, but it's correct that the library ignores the error e "reset" the text? I prefer to propagate the error so at editor level I can maintain the user text showing an error on a status bar, without loosing it, like in this example... image

pyscripter commented 4 years ago

Sure go ahead...

carloBarazzetta commented 4 years ago

Fixed, now it's possible to write incorrect svg text into editor (the icon disappear), and undo changes with "esc" or "ctrl-z" keys: the error appears at bottom-left of the component editor. Leaving the editor with wrong svg the icons remains blank. I've fixed also an error pressing "New" to create a blank icon ready to edit.

Serge-Girard commented 4 years ago

@Serge-Girard The European flag loads and renders correctly here with both factories. Are you using the latest version?

Surely not, I found your repository after my test with the Gitit version of Delphi 10.4.1

pyscripter commented 4 years ago

@Serge-Girard Then you might want to try with the master branch of this repository. It now loads the European flag Svg without issues. Which version of Windows are you using? The reason I am asking is that for Windows 10 with Creators update or later the default was the Direct2X Windows native factory, which does render the flag. @carloBarazzetta You may want to ask for an update of the Getit package. Also there may be some issues with the detection of the Creators Update. I was told that TOSVersion.Build sometimes returns 0.

carloBarazzetta commented 4 years ago

@carloBarazzetta You may want to ask for an update of the Getit package. Also there may be some issues with the detection of the Creators Update. I was told that TOSVersion.Build sometimes returns 0.

Yes, we can now release a new version and then asks to Serge Pilko to update Get-It Package