NS_IF_RELEASE(menu);
void nsPreviousMenuStackUnwind(nsIMenu * aMenuJustBuilt, MenuHandle aMenuHandleJustBuilt){  //printf("PreviousMenuStackUnwind called \n");  //printf("%d items on gPreviousMenuStack \n", gPreviousMenuStack.Count());  while (gPreviousMenuHandleStack.Count()) {    nsIMenu * menu = (nsIMenu *) gPreviousMenuStack[gPreviousMenuStack.Count() - 1];    MenuHandle menuHandle = (MenuHandle) gPreviousMenuHandleStack[gPreviousMenuHandleStack.Count() - 1];        //printf("  gPreviousMenuStack.Count() = %d \n", gPreviousMenuStack.Count());    //printf("  gPreviousMenuHandleStack.Count() = %d \n", gPreviousMenuHandleStack.Count());               if( menu && menuHandle ) {            if( menuHandle != aMenuHandleJustBuilt ) {           	      nsCOMPtr<nsIMenuListener> listener(do_QueryInterface(menu));		  if(listener) {		    //printf("MenuPop \n");		    		    nsMenuEvent mevent;		    mevent.message = NS_MENU_SELECTED;		    mevent.eventStructType = NS_MENU_EVENT;		    mevent.point.x = 0;		    mevent.point.y = 0;		    mevent.widget = nsnull;		    mevent.time = PR_IntervalNow();		    mevent.mCommand = (PRUint32) nsnull;		    		    // UNDO		    listener->MenuDeselected(mevent);		    		    gPreviousMenuStack.RemoveElementAt(gPreviousMenuStack.Count() - 1);	        //printf("%d items now on gPreviousMenuStack \n", gPreviousMenuStack.Count());	        gPreviousMenuHandleStack.RemoveElementAt(gPreviousMenuHandleStack.Count() - 1);	      		  }	  } else {        //printf("  gPreviousMenuStack.Count() = %d \n", gPreviousMenuStack.Count());        //printf("  gPreviousMenuHandleStack.Count() = %d \n", gPreviousMenuHandleStack.Count()); 	    return;	  }	}  }   //printf("  gPreviousMenuStack.Count() = %d \n", gPreviousMenuStack.Count());  //printf("  gPreviousMenuHandleStack.Count() = %d \n", gPreviousMenuHandleStack.Count()); }