You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Cameron McCormack <ca...@mcc.id.au> on 2009/03/19 05:11:45 UTC

Re: Second patch for JSVGComponent

Hi Bogdan.

Bogdan:
> This small patch fixes some potential and real NullPointerExceptions.

Thanks for the patch.  Some comments:

- if (at.equals(vt)) {
-   // No new transform
…
+ if (at != null) {
+   if (at.equals(vt)) {
+     // No new transform

I can’t see how at can be null.  AFAICT, calculateViewingTransform()
will always return an object.


- myCGN.setViewingTransform(myAT);
+ if (myCGN != null) myCGN.setViewingTransform(myAT);

For this one, yes, it seems myCGN can be null, if the GVT being
displayed in the component were messed with so that it doesn’t look
like:

  CompositeGraphicsNode
    +
    |
    +--CanvasGraphicsNode
         +
         :

since getCanvasGraphicsNode() will return null in this case.

JSVGComponent.setGraphicsNode(GraphicsNode,boolean) could also throw an
NPE if getCanvasGraphicsNode() returned null.

It seems a bit strange to allow messing with the GVT from outside the
JSVGComponent, but with the current design there’s not much we can do
about that, I think.

I’ve put the null check for the line in your patch and in
setGraphicsNode(GraphicsNode,boolean).

-- 
Cameron McCormack ≝ http://mcc.id.au/

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Second patch for JSVGComponent

Posted by Bogdan <bo...@op.pl>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Cameron McCormack wrote:
> Hi Bogdan.
> 
> Bogdan:
>> This small patch fixes some potential and real NullPointerExceptions.
> 
> Thanks for the patch.  Some comments:
> 
> - if (at.equals(vt)) {
> -   // No new transform
> …
> + if (at != null) {
> +   if (at.equals(vt)) {
> +     // No new transform
> 
> I can’t see how at can be null.  AFAICT, calculateViewingTransform()
> will always return an object.

 Perhaps. I'm not saying it returned null. I know I got a
NullPointerException and it was either 'myCGN' or 'at' that was null.
So I checked for both, just in case.

> - myCGN.setViewingTransform(myAT);
> + if (myCGN != null) myCGN.setViewingTransform(myAT);
> 
> For this one, yes, it seems myCGN can be null, if the GVT being
> displayed in the component were messed with so that it doesn’t look
> like:
> 
>   CompositeGraphicsNode
>     +
>     |
>     +--CanvasGraphicsNode
>          +
>          :
> 
> since getCanvasGraphicsNode() will return null in this case.

 I see. Well, I'm not messing with the internals of batik, but I'm
putting it under heavy stress, to see how my program behaves when it's
reaching the virtual machine's memory limit. This is how I got most of
the exceptions/problems I sent patches for.

> JSVGComponent.setGraphicsNode(GraphicsNode,boolean) could also throw an
> NPE if getCanvasGraphicsNode() returned null.

 Yes. I didn't notice that.

> It seems a bit strange to allow messing with the GVT from outside the
> JSVGComponent, but with the current design there’s not much we can do
> about that, I think.
> 
> I’ve put the null check for the line in your patch and in
> setGraphicsNode(GraphicsNode,boolean).

 OK, thanks!

- --
Pozdrawiam/Regards - Bogdan                     (GNU/Linux & FreeDOS)
Kurs asemblera x86 (DOS, GNU/Linux):http://rudy.mif.pg.gda.pl/~bogdro
Grupy dyskusyjne o asm:  pl.comp.lang.asm alt.pl.asm alt.pl.asm.win32
www.JabberPL.org www.TorProject.org Soft (EN): miniurl.pl/bogdro-soft
-----BEGIN PGP SIGNATURE-----

iD8DBQFJwoWsNTrTaBxW2h4RAzaRAJ9AzppKHw2vEvldoNkHT2EJ6FStWACdHNT+
H+oKUl/467Eq8xaodk76XwA=
=SaI9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org