Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328043 - ClassCastException in DisposeEvent
Summary: ClassCastException in DisposeEvent
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.4 M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 324443
  Show dependency tree
 
Reported: 2010-10-18 10:43 EDT by Steffen Kriese CLA
Modified: 2010-11-05 07:13 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Kriese CLA 2010-10-18 10:43:26 EDT
A call to notifyListeners(SWT.Dispose, event) on any widget, results in a ClassCastException. To reproduce it, just add the following lines to a widget like Text:

final Event newEvent = new Event();
newEvent.widget = this;
newEvent.type = SWT.Dispose;
newEvent.display = getDisplay();
notifyListeners(SWT.Dispose, newEvent);

This bug can also be reproduced by using the Riena ExampleClient and then go to Playground => Playground => Combos => CompletionCombo. 

Widget.notfyListener() calls UntypedEventAdapter.notifyListeners( final int eventType, final Event event ) which checks if it is a DisposeEventType and then tries to create a new DisposeEvent(event). DisposeEvent has a single argument constructor of type object, but the super constructor in TypedEvent expects the first parameter to be a widget. This of course results in a ClassCastException, because we passed in a Event instead of a Widget.

In my opinion UntypedEventAdapter should pass the widget from the source event to the new created DisposeEvent like: 


...
case SWT.Dispose:
        typedEvent = new DisposeEvent( event.widget);
  ...
Comment 1 Ivan Furnadjiev CLA 2010-11-05 07:04:03 EDT
Added missing ctor DisposeEvent( Event ). Fixed in CVS HEAD.