Bug 158876 [OpenModes] Synchronizer execs OpenStrategy Runnable mulitple times for one selection
So for the OpenStrategy I'm seeing mixed results for the call to display.asyncExec, where the SWT widgets Synchonizer will execute the runnable multiple times, although passed to asyncExec only once. See below code sample and debug output - any thoughts on why the synchronizer would execute the same runnable again and again? For context of the situation, this is in a TableViewer, with a content provider going against a server, leading to delays in scrolling when holding down the arrow key. Here's the code in OpenStrategy(for the places where the System.out.printlns are called to relate to the output listed below): System.out.println("Open Strategy Handling Event..."); ... ... display.asyncExec(new Runnable() { public void run() { if (arrowKeyDown) { System.out.println("Starting job: "+count[0]); display.timerExec(TIME, new Runnable() { int id = count[0]; public void run() { System.out.println("Trying to run job: "+id); if (id == count[0]) { System.out.println("Firing post selection: After 500 ms delay"); firePostSelectionEvent(new SelectionEvent( e)); if ((CURRENT_METHOD & ARROW_KEYS_OPEN) != 0) { System.out.println("Firing Open Event: After 500 ms delay"); fireOpenEvent(new SelectionEvent( e)); } } } }); } else { System.out.println("Firing post selection: Immediately "); firePostSelectionEvent(new SelectionEvent(e)); } } }); Then here's the output Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Trying to run job: 807 Trying to run job: 806 Trying to run job: 805 Trying to run job: 805 Trying to run job: 805 Trying to run job: 805 Trying to run job: 805 Trying to run job: 800 Trying to run job: 799 Trying to run job: 799 Trying to run job: 799 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Starting job: 818 Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Open Strategy Handling Event... Keydown handled from widget Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Open Strategy Handling Event... Keydown handled from widget Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent Trying to run job: 818 Firing post selection: After 500 ms delay selectionChangedEvent
bundles/org.eclipse.jface/src/org/eclipse/jface/util/OpenStrategy.java
/*
     * Fire the open event to all openEventListeners
     */
    private void fireOpenEvent(SelectionEvent e) {
        if (e.item != null && e.item.isDisposed()) {
			return;
		}
        Object l[] = openEventListeners.getListeners();
        for (int i = 0; i < l.length; i++) {
            ((IOpenEventListener) l[i]).handleOpen(e);
        }
    }
    
    private void initializeHandler(final Display display) {
        eventHandler = new Listener() {
            boolean timerStarted = false;
            Event mouseUpEvent = null;
            Event mouseMoveEvent = null;
            SelectionEvent selectionPendent = null;
            boolean enterKeyDown = false;
            SelectionEvent defaultSelectionPendent = null;
            boolean arrowKeyDown = false;
            final int[] count = new int[1];
            long startTime = System.currentTimeMillis();
            boolean collapseOccurred = false;
            boolean expandOccurred = false;
            public void handleEvent(final Event e) {
                if (e.type == SWT.DefaultSelection) {
                    SelectionEvent event = new SelectionEvent(e);
                    fireDefaultSelectionEvent(event);