Commit 14440ea
committed
Use
This simplifies the checks in the `PGbasicmacros.pl` `image` method that
determine if an image is an instance of a `Plots::Plot`, `WWPlot`, or
`LaTeXImage` package and makes it so that any future package that
derives from one of those will work without further modification to the
`image` method. This uses the `isa` method wrapped in an `eval`. So if
something is not blessed, the `isa` call will throw an exception, but
the `eval` catches the exception and ignores it returning false.
This is technically not quite as good as using
`blessed $image_item && $image_item->isa('Package::Name')`, but here
should be fine. The one case that this will now throw an exception for
that the `Scalar::Util::blessed` method would fix is if `$image_item` is
a literal package name that satisfies the `isa` call. For example if
someone were to call `image(WWPlot)` or `image('WWPlot')`. That will now
throw an uncaught exception, since `WWPlot->isa('WWPlot')` will not
throw an exception here and will return true. So the `insertGraph`
method will be called with the package name `WWPlot`, and that code will
throw the exception because it cannot work with the `WWPlot` package
name. That should not be a real problem though, since no one should do
that. Without this pull request that still wouldn't work, but it would
only give the warning "The file name "WWPlot" does not have an
extension. Every file name used as an argument to alias must have an
extension. The permissible extensions are .gif, .jpg, .png, .svg, .pdf,
.mp4, .mpg, .ogg, .webm, .css, .js, .nb, .csv, .tgz, and .html," but the
problem would still render. The same would happen for any package name
that derives from one of `WWPlot`, `Plots::Plot`, or `LaTeXImage`.isa to determine if a given image is a Plots::Plot, WWPlot, or LaTeXImage.1 parent ae1748f commit 14440ea
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2923 | 2923 | | |
2924 | 2924 | | |
2925 | 2925 | | |
2926 | | - | |
| 2926 | + | |
2927 | 2927 | | |
2928 | 2928 | | |
2929 | 2929 | | |
| |||
2942 | 2942 | | |
2943 | 2943 | | |
2944 | 2944 | | |
2945 | | - | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
2946 | 2948 | | |
2947 | 2949 | | |
2948 | 2950 | | |
| |||
0 commit comments