Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 9847 - Embedded Swing hangs eclipse when editor closes
Summary: Embedded Swing hangs eclipse when editor closes
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 37724
  Show dependency tree
 
Reported: 2002-02-14 14:36 EST by David Mitchell CLA
Modified: 2004-06-09 23: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 David Mitchell CLA 2002-02-14 14:36:50 EST
Summary:

Swing hangs eclipse when embedded within a MultiPageEditorPart 
and the editor is used, and then closed. 

Build: Stable build 20020125

Details:
There are two pages within the editor.  One is just a SWT control within
a composite.  The other page is embedded swing controls.

I've created an AWT Panel using SWT_AWT.new_Panel , added a 
JLayeredPane to the Panel, and then added three JButtons to 
the JLayeredPane.

The code to do this is here:

protected void createSwingPage(){
  Composite composite = new Composite(getContainer(), SWT.NONE);
  final Display display = Display.getCurrent();

  Panel awtPanel = SWT_AWT.new_Panel(composite);
  awtPanel.setLayout(new BorderLayout());

  JLayeredPane layeredPane = new JLayeredPane();
  layeredPane.setLayout(new FlowLayout());
  awtPanel.add(layeredPane);

  final JButton jbutton = new JButton("Test");
  jbutton.addActionListener(new ActionListener () {
    public void actionPerformed (ActionEvent event) {
      display.asyncExec(new Runnable () {
        public void run () {
          SwingUtilities.invokeLater(new Runnable(){
            public void run(){
              jbutton.setText ("Swing Button Selected");
            }
          });
        }
      });
    }
  });

  layeredPane.add(jbutton);
  layeredPane.add(new JButton("test2"));
  layeredPane.add(new JButton("test3"));

  int index = addPage(composite);
  setPageText(index, "Swing");
}


This is the behavior I've noticed.
1. If the editor is launched, and then closed immediately, there is no 
   problem

2. If the editor is launched, and then a swing event is executed 
  (click on a button), and then the editor is closed, eclipse hangs

3. If the editor is lauched, a swing event is executed (click on a button),
  then another tab of the MultiPageEditorPart is clicked on, and then
  the editor is closed, there is no problem.

All the other tests I have done are basically permutations of this.  Things 
like changing the perspective, have the same effect as clicking on the
tab, but things like selecting a menu item do not.

It appears that if an SWT event is fired which either changes the focus or
visibility of the swing controls after a Swing event has been fired
there is no problem. Anything else seems to hang eclipse.

I've also done some looking at the dispose events, and apparently the 
behavior happens after the dispose event of the Composite object, but 
prior to the dispose of the editor itself.

Please note, this behavior happens when the editor is disposed, and it 
doesn't matter if it is due to eclipse being closed, or just the editor.  
The problem happens reguardless.

I haven't tested this on different windows platforms, but have tested it 
on different machines, with the same results.

I also noticed that one of the examples provided in the newsgroups which 
details how to embed swing within SWT had the same problems on my 
machine when run from within a eclipse debug session.  I haven't tested 
it on another machine or outside an eclipse debug session.
Comment 1 Veronika Irvine CLA 2002-05-27 10:30:51 EDT
Later.
Comment 2 Veronika Irvine CLA 2002-09-10 10:25:45 EDT
Post 2.0. Re-opening bug reports for review.
Comment 3 David Mitchell CLA 2003-02-12 13:08:35 EST
Here is a message I got from Leonard Norrgard [lkn@acm.org] about this:

"I started looking into this today.  It seems to be the same bug I saw 
myself with OTI's SWT_AWT code. My EmbeddedSwing solution doesn't have 
this problem. I will however continue to look into your example code 
tomorrow - I'm condensing it to a simple-as-possible standalone SWT 
application so that I can then change that code to be based on the 
EmbeddedSwing component."
Comment 4 Leonard Norrgard CLA 2003-02-12 17:45:57 EST
How quick a year passes -- I sent that email to David on 20th February, 2002.

The solution still exists. I guess I should revive the efforts to get it
published. Nothing has happened since the end of October on getting it
published, because I haven't set aside time for it.
Comment 5 Steve Northover CLA 2004-06-09 22:01:42 EDT
Does this still happen?
Comment 6 Silenio Quarti CLA 2004-06-09 23:26:50 EDT
No, this is fixed in latest.