Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331288 - Problem in UntypedEventAdapter - the state of event.doit is not persisted
Summary: Problem in UntypedEventAdapter - the state of event.doit is not persisted
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 223852
Blocks:
  Show dependency tree
 
Reported: 2010-11-28 15:40 EST by PSko CLA
Modified: 2012-10-27 08:19 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 PSko CLA 2010-11-28 15:40:02 EST
Build Identifier: 1.3.0.20100615-1704

There's a problem in UntypedEventAdapter, in some cases the state of event.doit is not being translated to so called Typed? Event (ex: Event -> [Shell]Event). 

This problem make impossible to protect:
- the user against closing the window by mistake (when unsaved data present etc),
- the user against entering unwanted characters in the input box (VerifyEvent).


My quick solution is to apply the following patch:

diff -u UntypedEventAdapter.java.org UntypedEventAdapter.java
--- UntypedEventAdapter.java.org	2010-09-20 22:29:04.000000000 +0200
+++ UntypedEventAdapter.java	2010-09-20 22:29:07.000000000 +0200
@@ -86,6 +86,7 @@
     Event event = createEvent( SWT.Selection, evt.getSource() );
     copyFields( evt, event );
     dispatchEvent( event );
+    evt.doit = event.doit;
   }
 
   public void focusGained( final FocusEvent evt ) {
@@ -122,12 +123,14 @@
     Event event = createEvent( SWT.Close, evt.getSource() );
     copyFields( evt, event );
     dispatchEvent( event );
+    evt.doit = event.doit;
   }
 
   public void shellDeactivated( final ShellEvent evt ) {
     Event event = createEvent( SWT.Deactivate, evt.getSource() );
     copyFields( evt, event );
     dispatchEvent( event );
+    evt.doit = event.doit;
   }
 
   public void menuHidden( final MenuEvent evt ) {
@@ -152,6 +155,7 @@
     Event event = createEvent( SWT.Verify, evt.getSource() );
     copyFields( evt, event );
     dispatchEvent( event );
+    evt.doit = event.doit;
   }
 
   public void update( final SetDataEvent evt ) {



Reproducible: Always

Steps to Reproduce:
1. Add the event handler to protect against closing the Shell 
2. Try to close the shell via UI
3. SWT.Deactivate event is sent, set event.doit to false value
4. The shell is being close. The state of event.doit is lost, it is not being translated to ShellEvent.

I can see lots of places in UntypedEventAdapter where the state of event is not being translated back to *Event. Quick fix attached in Details.
Comment 1 Ralf Sternberg CLA 2012-10-27 08:19:13 EDT
The event system has been rewritten (see bug bug 334028). UntypedEventAdapter is gone and all flags are copied from untyped to typed events in the same way as in SWT.