Program: 58947
Project: 58947
Buggy source:
/** 
 * This method has to be called in every display step. It is responsible for the picking. It needs the ID of the calling view and a gl context.
 * @param iViewID the id of the calling view
 * @param gl the GL context
 * @param bIsMaster TODO remove after some testing - not needed at themoment. remove deprecated when done
 */
@Deprecated public void handlePicking(final int iViewID,final GL gl,final boolean bIsMaster){
  if (bEnablePicking == false)   return;
  AGLEventListener canvasUser=(GeneralManager.get().getViewGLCanvasManager().getGLEventListener(iViewID));
  PickingJoglMouseListener pickingTriggerMouseAdapter=canvasUser.getParentGLCanvas().getJoglMouseListener();
  Point pickPoint=null;
  EPickingMode ePickingMode=EPickingMode.CLICKED;
  if (pickingTriggerMouseAdapter.wasMouseDoubleClicked()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.DOUBLE_CLICKED;
  }
 else   if (pickingTriggerMouseAdapter.wasLeftMouseButtonPressed()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.CLICKED;
  }
 else   if (pickingTriggerMouseAdapter.wasMouseDragged()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.DRAGGED;
  }
 else   if (pickingTriggerMouseAdapter.wasMouseMoved()) {
    hashViewIDToLastMouseMovedTimeStamp.put(iViewID,System.nanoTime());
    hashViewIDToIsMouseOverPickingEvent.put(iViewID,true);
  }
 else   if (hashViewIDToIsMouseOverPickingEvent.get(iViewID) != null && hashViewIDToLastMouseMovedTimeStamp.get(iViewID) != null && hashViewIDToIsMouseOverPickingEvent.get(iViewID) == true && System.nanoTime() - hashViewIDToLastMouseMovedTimeStamp.get(iViewID) >= 0) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    hashViewIDToLastMouseMovedTimeStamp.put(iViewID,System.nanoTime());
    ePickingMode=EPickingMode.MOUSE_OVER;
  }
  if (pickPoint == null) {
    return;
  }
  hashViewIDToIsMouseOverPickingEvent.put(iViewID,false);
  int PICKING_BUFSIZE=1024;
  int iArPickingBuffer[]=new int[PICKING_BUFSIZE];
  IntBuffer pickingBuffer=BufferUtil.newIntBuffer(PICKING_BUFSIZE);
  int iHitCount=-1;
  int viewport[]=new int[4];
  gl.glGetIntegerv(GL.GL_VIEWPORT,viewport,0);
  gl.glSelectBuffer(PICKING_BUFSIZE,pickingBuffer);
  gl.glRenderMode(GL.GL_SELECT);
  gl.glInitNames();
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  GLU glu=new GLU();
  glu.gluPickMatrix(pickPoint.x,(viewport[3] - pickPoint.y),5.0,5.0,viewport,0);
  float fAspectRatio=(float)(viewport[3] - viewport[1]) / (float)(viewport[2] - viewport[0]);
  IViewFrustum viewFrustum=canvasUser.getViewFrustum();
  viewFrustum.setProjectionMatrix(gl,fAspectRatio);
  gl.glMatrixMode(GL.GL_MODELVIEW);
  Point tmpPickPoint=(Point)pickPoint.clone();
  pickPoint=null;
  canvasUser.display(gl);
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL.GL_MODELVIEW);
  iHitCount=gl.glRenderMode(GL.GL_RENDER);
  pickingBuffer.get(iArPickingBuffer);
  ArrayList<Integer> iAlPickedObjectId=processHits(iHitCount,iArPickingBuffer);
  if (iAlPickedObjectId.size() > 0) {
    processPicks(iAlPickedObjectId,iViewID,ePickingMode,bIsMaster,tmpPickPoint,pickingTriggerMouseAdapter.getPickedPointDragStart());
  }
}

Fixed version (ground truth):
/** 
 * This method has to be called in every display step. It is responsible for the picking. It needs the ID of the calling view and a gl context.
 * @param iViewID the id of the calling view
 * @param gl the GL context
 * @param bIsMaster TODO remove after some testing - not needed at themoment. remove deprecated when done
 */
@Deprecated public void handlePicking(final int iViewID,final GL gl,final boolean bIsMaster){
  if (bEnablePicking == false)   return;
  AGLEventListener canvasUser=(GeneralManager.get().getViewGLCanvasManager().getGLEventListener(iViewID));
  PickingJoglMouseListener pickingTriggerMouseAdapter=canvasUser.getParentGLCanvas().getJoglMouseListener();
  Point pickPoint=null;
  EPickingMode ePickingMode=EPickingMode.CLICKED;
  if (pickingTriggerMouseAdapter.wasMouseDoubleClicked()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.DOUBLE_CLICKED;
  }
 else   if (pickingTriggerMouseAdapter.wasLeftMouseButtonPressed()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.CLICKED;
  }
 else   if (pickingTriggerMouseAdapter.wasMouseDragged()) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.DRAGGED;
  }
 else   if (pickingTriggerMouseAdapter.wasMouseMoved()) {
    hashViewIDToIsMouseOverPickingEvent.put(iViewID,true);
  }
 else   if (hashViewIDToIsMouseOverPickingEvent.get(iViewID) != null && hashViewIDToIsMouseOverPickingEvent.get(iViewID) == true) {
    pickPoint=pickingTriggerMouseAdapter.getPickedPoint();
    ePickingMode=EPickingMode.MOUSE_OVER;
  }
  if (pickPoint == null) {
    return;
  }
  hashViewIDToIsMouseOverPickingEvent.put(iViewID,false);
  int PICKING_BUFSIZE=1024;
  int iArPickingBuffer[]=new int[PICKING_BUFSIZE];
  IntBuffer pickingBuffer=BufferUtil.newIntBuffer(PICKING_BUFSIZE);
  int iHitCount=-1;
  int viewport[]=new int[4];
  gl.glGetIntegerv(GL.GL_VIEWPORT,viewport,0);
  gl.glSelectBuffer(PICKING_BUFSIZE,pickingBuffer);
  gl.glRenderMode(GL.GL_SELECT);
  gl.glInitNames();
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  GLU glu=new GLU();
  glu.gluPickMatrix(pickPoint.x,(viewport[3] - pickPoint.y),5.0,5.0,viewport,0);
  float fAspectRatio=(float)(viewport[3] - viewport[1]) / (float)(viewport[2] - viewport[0]);
  IViewFrustum viewFrustum=canvasUser.getViewFrustum();
  viewFrustum.setProjectionMatrix(gl,fAspectRatio);
  gl.glMatrixMode(GL.GL_MODELVIEW);
  Point tmpPickPoint=(Point)pickPoint.clone();
  pickPoint=null;
  canvasUser.display(gl);
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL.GL_MODELVIEW);
  iHitCount=gl.glRenderMode(GL.GL_RENDER);
  pickingBuffer.get(iArPickingBuffer);
  ArrayList<Integer> iAlPickedObjectId=processHits(iHitCount,iArPickingBuffer);
  if (iAlPickedObjectId.size() > 0) {
    processPicks(iAlPickedObjectId,iViewID,ePickingMode,bIsMaster,tmpPickPoint,pickingTriggerMouseAdapter.getPickedPointDragStart());
  }
}