Program: 57685
Project: 57685
Buggy source:
/** 
 * This method has to be called in every display step. It is responsible for the ray tracing which does the actual picking. It needs the ID of the calling view and a gl context. It calls the display() method of the calling view, therefore only elements rendered in the display() can be picked.
 * @param glView a reference to the calling view
 * @param gl the GL2 context
 */
public void handlePicking(final AGLView glView,final GL2 gl){
  if (enablePicking == false)   return;
  GLMouseListener glMouseListener=glView.getGLMouseListener();
  Point pickPoint=null;
  PickingMode ePickingMode=PickingMode.CLICKED;
  if (glMouseListener.wasMouseDoubleClicked()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.DOUBLE_CLICKED;
  }
 else   if (glMouseListener.wasMouseDragged()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.DRAGGED;
  }
 else   if (glMouseListener.wasLeftMouseButtonPressed()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.CLICKED;
  }
 else   if (glMouseListener.wasRightMouseButtonPressed()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.RIGHT_CLICKED;
  }
 else   if (glMouseListener.wasMouseMoved()) {
    hashViewIDToIsMouseOverPickingEvent.put(glView.getID(),true);
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.MOUSE_OVER;
  }
 else   if (hashViewIDToIsMouseOverPickingEvent.get(glView.getID()) != null && hashViewIDToIsMouseOverPickingEvent.get(glView.getID()) == true) {
  }
  if (pickPoint == null)   return;
  hashViewIDToIsMouseOverPickingEvent.put(glView.getID(),false);
  int PICKING_BUFSIZE=1024;
  int iArPickingBuffer[]=new int[PICKING_BUFSIZE];
  IntBuffer pickingBuffer=Buffers.newDirectIntBuffer(PICKING_BUFSIZE);
  int iHitCount=-1;
  int viewport[]=new int[4];
  gl.glGetIntegerv(GL2.GL_VIEWPORT,viewport,0);
  gl.glSelectBuffer(PICKING_BUFSIZE,pickingBuffer);
  gl.glRenderMode(GL2.GL_SELECT);
  gl.glInitNames();
  gl.glMatrixMode(GL2.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]);
  ViewFrustum viewFrustum=glView.getViewFrustum();
  viewFrustum.setProjectionMatrix(gl,fAspectRatio);
  Point tmpPickPoint=(Point)pickPoint.clone();
  pickPoint=null;
  glView.display(gl);
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  iHitCount=gl.glRenderMode(GL2.GL_RENDER);
  pickingBuffer.get(iArPickingBuffer);
  ArrayList<Integer> iAlPickedObjectId=processHits(iHitCount,iArPickingBuffer);
  if (iAlPickedObjectId.size() > 0) {
    processPicks(iAlPickedObjectId,ePickingMode,tmpPickPoint,glMouseListener.getPickedPointDragStart());
  }
 else {
    GLCanvas parentCanvas=glView.getParentGLCanvas();
    for (    int viewID : hashViewIDToPreviousViewSpecificHitListContainer.keySet()) {
      AGLView currentView=GeneralManager.get().getViewManager().getGLView(viewID);
      if (currentView != null && currentView.getParentGLCanvas() == parentCanvas) {
        ViewSpecificHitListContainer previousHitContainer=hashViewIDToPreviousViewSpecificHitListContainer.get(viewID);
        if (previousHitContainer != null) {
          for (          String pickingType : previousHitContainer.getPickingTypes()) {
            for (            Pick previousPick : previousHitContainer.getPicksForPickingType(pickingType)) {
              ViewSpecificHitListContainer hitContainer=hashViewIDToViewSpecificHitListContainer.get(viewID);
              if (hitContainer == null) {
                hitContainer=new ViewSpecificHitListContainer();
                hashViewIDToViewSpecificHitListContainer.put(viewID,hitContainer);
              }
              Pick pick=new Pick(previousPick.getObjectID(),PickingMode.MOUSE_OUT,tmpPickPoint,glMouseListener.getPickedPointDragStart(),fMinimumZValue);
              hitContainer.addPicksForPickingType(pickingType,pick,true);
            }
          }
        }
        hashViewIDToPreviousViewSpecificHitListContainer.put(viewID,new ViewSpecificHitListContainer());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method has to be called in every display step. It is responsible for the ray tracing which does the actual picking. It needs the ID of the calling view and a gl context. It calls the display() method of the calling view, therefore only elements rendered in the display() can be picked.
 * @param glView a reference to the calling view
 * @param gl the GL2 context
 */
public void handlePicking(final AGLView glView,final GL2 gl){
  if (enablePicking == false)   return;
  GLMouseListener glMouseListener=glView.getGLMouseListener();
  Point pickPoint=null;
  PickingMode ePickingMode=PickingMode.CLICKED;
  if (glMouseListener.wasMouseDoubleClicked()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.DOUBLE_CLICKED;
  }
 else   if (glMouseListener.wasMouseDragged()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.DRAGGED;
  }
 else   if (glMouseListener.wasLeftMouseButtonPressed()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.CLICKED;
  }
 else   if (glMouseListener.wasRightMouseButtonPressed()) {
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.RIGHT_CLICKED;
  }
 else   if (glMouseListener.wasMouseMoved()) {
    hashViewIDToIsMouseOverPickingEvent.put(glView.getID(),true);
    pickPoint=glMouseListener.getPickedPoint();
    ePickingMode=PickingMode.MOUSE_OVER;
  }
 else   if (hashViewIDToIsMouseOverPickingEvent.get(glView.getID()) != null && hashViewIDToIsMouseOverPickingEvent.get(glView.getID()) == true) {
  }
  if (pickPoint == null)   return;
  hashViewIDToIsMouseOverPickingEvent.put(glView.getID(),false);
  int PICKING_BUFSIZE=1024;
  int iArPickingBuffer[]=new int[PICKING_BUFSIZE];
  IntBuffer pickingBuffer=Buffers.newDirectIntBuffer(PICKING_BUFSIZE);
  int iHitCount=-1;
  int viewport[]=new int[4];
  gl.glGetIntegerv(GL2.GL_VIEWPORT,viewport,0);
  gl.glSelectBuffer(PICKING_BUFSIZE,pickingBuffer);
  gl.glRenderMode(GL2.GL_SELECT);
  gl.glInitNames();
  gl.glMatrixMode(GL2.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]);
  ViewFrustum viewFrustum=glView.getViewFrustum();
  viewFrustum.setProjectionMatrix(gl,fAspectRatio);
  Point tmpPickPoint=(Point)pickPoint.clone();
  pickPoint=null;
  glView.display(gl);
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  iHitCount=gl.glRenderMode(GL2.GL_RENDER);
  pickingBuffer.get(iArPickingBuffer);
  ArrayList<Integer> iAlPickedObjectId=processHits(iHitCount,iArPickingBuffer);
  GLCanvas parentCanvas=glView.getParentGLCanvas();
  if (iAlPickedObjectId.size() > 0) {
    processPicks(iAlPickedObjectId,ePickingMode,tmpPickPoint,glMouseListener.getPickedPointDragStart());
    Set<Integer> processedViews=new HashSet<Integer>();
    for (    int pickingID : iAlPickedObjectId) {
      Pair<Integer,String> pickAssociatedValues=hashPickingIDToViewID.get(pickingID);
      int pickedViewID=pickAssociatedValues.getFirst();
      for (      int viewID : hashViewIDToPreviousViewSpecificHitListContainer.keySet()) {
        if (viewID != pickedViewID && !processedViews.contains(viewID)) {
          AGLView currentView=GeneralManager.get().getViewManager().getGLView(viewID);
          if (currentView != null && currentView.getParentGLCanvas() == parentCanvas && !isParentViewOfView(pickedViewID,viewID)) {
            ViewSpecificHitListContainer previousHitContainer=hashViewIDToPreviousViewSpecificHitListContainer.get(viewID);
            if (previousHitContainer != null) {
              for (              String pickingType : previousHitContainer.getPickingTypes()) {
                for (                Pick previousPick : previousHitContainer.getPicksForPickingType(pickingType)) {
                  if (!pickingType.equals(pickAssociatedValues.getSecond()) && previousPick.getObjectID() != getPickedObjectIDFromPickingID(pickedViewID,pickAssociatedValues.getSecond(),pickingID)) {
                    ViewSpecificHitListContainer hitContainer=hashViewIDToViewSpecificHitListContainer.get(viewID);
                    if (hitContainer == null) {
                      hitContainer=new ViewSpecificHitListContainer();
                      hashViewIDToViewSpecificHitListContainer.put(viewID,hitContainer);
                    }
                    Pick pick=new Pick(previousPick.getObjectID(),PickingMode.MOUSE_OUT,tmpPickPoint,glMouseListener.getPickedPointDragStart(),fMinimumZValue);
                    hitContainer.addPicksForPickingType(pickingType,pick,true);
                    processedViews.add(viewID);
                  }
                }
              }
            }
            hashViewIDToPreviousViewSpecificHitListContainer.put(viewID,new ViewSpecificHitListContainer());
          }
        }
      }
    }
  }
 else {
    Set<Integer> remoteRenderedViewIDs=new HashSet<Integer>();
    for (    int viewID : hashViewIDToPreviousViewSpecificHitListContainer.keySet()) {
      AGLView currentView=GeneralManager.get().getViewManager().getGLView(viewID);
      if (currentView != null && currentView.getParentGLCanvas() == parentCanvas) {
        remoteRenderedViewIDs.add(viewID);
      }
    }
    addMouseOutForPicksOfSpecifiedViews(remoteRenderedViewIDs,glMouseListener,tmpPickPoint);
  }
}