[OpenMap Users] Problem in OMGraphicList

From: Swt <stephane.wasserhardt_at_email.domain.hidden>
Date: Mon Jan 07 2008 - 07:36:40 EST

 Hello !

There is a little problem in OMGraphicList, when calling the "findAllTest" method.
This typically happens when the user clicks on a map which contains an OMGraphicHandlerLayer with a StandardMapMouseInterpreter (DrawingEditorTool), because the "mousePressed" method calls "getGeometryUnder" which then calls "findAllTest"... And if a OMGraphic in the layer's graphics list is not visible, a NullPointerException is thrown.
Here is the code :

omd = findClosestTest(omd,
                    0 /* doesn't matter */,
                    omg,
                    x,
                    y,
                    limit,
                    resetSelect);
            
if (omg == null || omd.omg == null) {
     // no hit, but continue testing...
     return true;
}

The method "findClosestTest" can return a null value, which lead to a NullPointerException when resolving "omd.omg".
Here are two valid fixes for this problem :

1) Modify "findClosestTest" in order to garantee that it returns a non-null OMDist object.
2) Handle the null return value.

Details :
1) In "findClosestTest", change :

// cannot select a graphic which isn't visible
if (!shouldProcess(graphic)) {
     return null;
}

To :

// cannot select a graphic which isn't visible
if (!shouldProcess(graphic)) {
     return current;
}

Because "current" is a pre-allocated result OMDist object.

2) In "findAllTest", change :

if (omg == null || omd.omg == null) {
     // no hit, but continue testing...
     return true;
}

To :

if (omg == null || omd == null || omd.omg == null) {
     // no hit, but continue testing...
     return true;
}

Regards.

Stephane

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Jan 7 08:08:31 2008

This archive was generated by hypermail 2.1.8 : Mon Jan 07 2008 - 08:08:31 EST