SVGIconImageList icon indicating copy to clipboard operation
SVGIconImageList copied to clipboard

Error when defining PreferNativeSvgSupport

Open groehner opened this issue 9 months ago • 12 comments

Due to F. In SVGIconImageList\Source\SVGIconImageList.inc define PreferNativeSvgSupport

in https://github.com/pyscripter/pyscripter/blob/master/Compilation%20Instructions.txt

I activated PreferNativeSvgSupport

but then i get an error in SVGInterfaces due to a missing comma between the unit Image32SVGFactory and D2DSVGFactory

groehner avatar Feb 20 '25 09:02 groehner

It used to be like this

  {$IFDEF PreferNativeSvgSupport}
    {$IFNDEF SvgDisableEngineHint}
    {$MESSAGE HINT 'but Prefer Windows Direct-2D SVG-Engine if available'}
    {$ENDIF}
    , D2DSVGFactory
  {$ENDIF}

for some reason the comma is now missing.

pyscripter avatar Feb 20 '25 10:02 pyscripter

I'm getting old! ;-)

carloBarazzetta avatar Feb 20 '25 12:02 carloBarazzetta

Probably that was a Monk moment. You felt like this looks untidy :)

luebbe avatar Feb 20 '25 12:02 luebbe

To @groehner By the way, why use D2DSVGFactory as the default, when Image32 is superior in both performance and SVG support? Look at this page: https://ethea.it/docs/svgiconimagelist/SVG-Viewer-(VCL).html Do you have some svg that Image32 cannot render properly? Image32 is the best "native" Delphi implementation for SVG, at the moment (and no dlls like Skia4Delphi are needed)

carloBarazzetta avatar Feb 20 '25 15:02 carloBarazzetta

I was just following pyscripters instruction to "define PreferNativeSvgSupport"

I got two errors like this due to missing "" Image

Translation: Error reading TSVGIconItem.SVGText: Error parsing SVGText: A call to an operating system function failed. Ignore the error and continue? NOTE: Ignoring the error may delete components or lose property values.

groehner avatar Feb 21 '25 07:02 groehner

Please attach the svg file that cause this error...

carloBarazzetta avatar Feb 27 '25 10:02 carloBarazzetta

@carloBarazzetta This is not about a specific svg. The code does not compile with PreferNativeSvgSupport.

  {$IFDEF PreferNativeSvgSupport}
    {$IFNDEF SvgDisableEngineHint}
    {$MESSAGE HINT 'but Prefer Windows Direct-2D SVG-Engine if available'}
    {$ENDIF}
    , D2DSVGFactory
  {$ENDIF}

The comma is now missing.

pyscripter avatar Feb 27 '25 10:02 pyscripter

Yes, I've already fixed this, but @groehner showed here another problem: "A call to an operating system function failed": I didn't understand how it happens...

carloBarazzetta avatar Feb 27 '25 10:02 carloBarazzetta

Sorry I missed that.

pyscripter avatar Feb 27 '25 10:02 pyscripter

Please attach the svg file that cause this error...

It wasn't a separate svg-file but an icon definition in the SVG Icon ImageLise editor, with missing the end tag i. e. <svg viewBox="0 -0.5 16 16">

groehner avatar Feb 27 '25 11:02 groehner

Some days ago I got such exceptions:

Image

My investigation took me to this point:

Unit TB2Common
procedure SpDrawVirtualImageList(ACanvas: TCanvas; const ARect: TRect;  
...
    if SpIsVirtualImageList(ImageList) then begin
      RttiC := TRttiContext.Create;
      IC := RttiC.GetType(ImageList.ClassType).GetProperty('ImageCollection').GetValue(ImageList).AsObject;
      if Assigned(IC) then begin

        // Replace ImageIndex with IL.Images[ImageIndex].CollectionIndex
        ILItems := RttiC.GetType(ImageList.ClassType).GetProperty('Images').GetValue(ImageList).AsObject;
        ILItem := RttiC.GetType(ILItems.ClassType).GetIndexedProperty('Items').GetValue(ILItems, [ImageIndex]).AsObject;
        ImageIndex := RttiC.GetType(ILItem.ClassType).GetProperty('CollectionIndex').GetValue(ILItem).AsInteger;

An ImageIndex of an TVirtualImageList shall be converted to an CollectionIndex of a TSVGIconImageCollection but ImageIndex got -1 which leads to the exception.

I controlled the VirtualimageList and the SVGIconImageCollection. They both show the same ImageName. But still this error appears

As Workaround I change a little bit the Imagename in VirtualimageList and the SVGIconImageCollection and then the error is gone.

groehner avatar Feb 27 '25 11:02 groehner

Sorry for the missing file. Here my next try.

<svg viewBox="0 -0.5 16 16">
<path stroke="#7e7c73" d="M1 1h1" />
<path stroke="#565249" d="M2 1h1M1 2h1M1 3h1M1 4h1M1 5h1M1 6h1M1 7h1M1 8h1M1 9h1M1 10h1M1 11h1M1 12h1M1 13h1" />
<path stroke="#000000" d="M2 2h1M2 3h1M2 4h1M2 5h1M2 6h1M2 7h1M2 8h1M2 9h1M2 10h1M2 11h1M2 12h1M2 13h1M1 14h2" />
<path stroke="#4f623b" d="M4 2h12M4 3h1M15 3h1M4 4h1M15 4h1M4 5h1M15 5h1M4 6h12" />
<path stroke="#cedbc1" d="M5 3h1" />
<path stroke="#b5c7a2" d="M6 3h6M5 4h1M5 5h1" />
<path stroke="#b7c9a4" d="M12 3h1" />
<path stroke="#b8caa5" d="M13 3h1" />
<path stroke="#b9caa7" d="M14 3h1" />
<path stroke="#90ab73" d="M6 4h3M6 5h2" />
<path stroke="#92ad75" d="M9 4h1M8 5h1" />
<path stroke="#97b17d" d="M10 4h1" />
<path stroke="#99b37e" d="M11 4h1M10 5h1" />
<path stroke="#9bb481" d="M12 4h1M11 5h1" />
<path stroke="#9db683" d="M13 4h1" />
<path stroke="#9fb786" d="M14 4h1" />
<path stroke="#93ae78" d="M9 5h1" />
<path stroke="#9cb582" d="M12 5h1" />
<path stroke="#9eb685" d="M13 5h1" />
<path stroke="#a0b887" d="M14 5h1" />
<path stroke="#344f6b" d="M4 8h7M4 9h1M10 9h1M4 10h1M10 10h1M4 11h1M10 11h1M4 12h7" />
<path stroke="#c2cddb" d="M5 9h1" />
<path stroke="#a3b4c8" d="M6 9h2M5 10h1M5 11h1" />
<path stroke="#a3b5c8" d="M8 9h1" />
<path stroke="#a5b6c9" d="M9 9h1" />
<path stroke="#7a94b2" d="M6 10h1" />
<path stroke="#7c96b3" d="M7 10h1M6 11h1" />
<path stroke="#7e98b5" d="M8 10h1M7 11h1" />
<path stroke="#809ab7" d="M9 10h1M8 11h1" />
<path stroke="#829cb8" d="M9 11h1" />

As you can see the closing svg end tag </svg> is missing. This caused the exception I mentioned last week. This exception confused me at first, but it's ok because it led me to this faulty SVG text, which is now corrected.

groehner avatar Mar 02 '25 09:03 groehner