[OpenMap Users] Problem in OMGraphicList

From: Swt <stephane.wasserhardt_at_magellium.fr>
Date: Mon, 7 Jan 2008 13:36:40 +0100

 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_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Jan 07 2008 - 08:00:50 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT