Bug 385729 - widget event handling inconsistency
Summary: widget event handling inconsistency
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2012-07-23 09:35 EDT by Levente Farkas CLA
Modified: 2018-04-13 15:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Levente Farkas CLA 2012-07-23 09:35:52 EDT
Build Identifier: 3.6.1-6.13.el6.x86_64

The display.postEvent(event) func put into the Display's eventQueue the given event ("deferredEvents"). the base problem is that if the eventTable once already added a listener for a given widget that it never become null even if we remove all listener. so even if the table is empty or not the given event put into the Display's eventQueue. it doesn't seem to valid that the event post happened after a addListener/removeListener call but not before this.
this is how the sendEvent look like on Widget.java:
-------------------------------
void sendEvent (int eventType, Event event, boolean send) {
    if (eventTable == null && !display.filters (eventType)) {
        return;
    }
    if (event == null) event = new Event ();
    event.type = eventType;
    event.display = display;
    event.widget = this;
    if (event.time == 0) {
        event.time = display.getLastEventTime ();
    }
    if (send) {
        sendEvent (event);
    } else {
        display.postEvent (event);
    }
}
-------------------------------
in Display.java it's properly implemented in this way
-------------------------------
public void removeFilter (int eventType, Listener listener) {
    checkDevice ();
    if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
    if (filterTable == null) return;
    filterTable.unhook (eventType, listener);
    if (filterTable.size () == 0) filterTable = null;
}
-------------------------------
while in Widget.java the last if is missing which cause the problem:
-------------------------------
public void removeListener (int eventType, Listener listener) {	
	checkWidget ();
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
	if (eventTable == null) return;
	eventTable.unhook (eventType, listener);
}
-------------------------------


Reproducible: Always
Comment 1 Eric Williams CLA 2018-04-13 15:26:53 EDT
This is no longer the case.