[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Opening OS dialog stalls GUI events

Could this be related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=88958 
?

"Joshua Salit" <jrsalit@xxxxxxxxxx> wrote in message 
news:dmpsec$u8n$1@xxxxxxxxxxxxxxxxxxx
> Hi,
> When you open an operating system supplied dialog, such as
> swt.widgets.FileDialog (on Windows, at least, it's provided by a native
> function org.eclipse.swt.internal.win32.GetOpenFileNameA()), the event
> thread seems to stall until the dialog has closed.
>
> Now, I can sort of understand this would be out of Eclipse's control, as
> the Windows dialog is modal and probably just somehow stops the
> display's event thread from getting events.  But I'll give an example of
> an application where this becomes a little annoying - imagine something
> like a performance monitor, showing graphs/charts that are constantly
> updated.  As soon as you open a dialog, these graphs stop updating until
> the dialog is closed.  Not SO bad, as long as the user realizes this is
> happening.  But if the user happened to not notice that the charts in
> the background were no longer updating, and a critical situation arose
> in the charts that they didn't/couldn't see, then this situation becomes
> a little worse.
>
> I've attached an example to reproduce this problem...it's a modification
> of a few snippets, which starts adding items to a table in a thread, and
> then after 25 items have been added, it pops up a FileDialog.  The thing
> to notice is that while the FileDialog is opened, no more items are
> (visibly) added to the table.  When the FileDialog is closed, the table
> catches up with itself pretty quickly.
>
> Sorry if the code is a bit messy, it's short at least.
>
> Although I'm pretty sure this is currently working-as-designed, it's
> causing a bit of a problem for me so I thought I'd ask.  I'd appreciate
> hearing what others think of this...if there's something obvious I am
> missing that would allow me to work around this, or if this is worth
> opening a bug report for, etc..
>
> Thank you!
>


--------------------------------------------------------------------------------


> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.*;
>
> public class TableDialogTest {
>
> public static void main (String [] args) {
> final Display display = new Display ();
> final Shell shell = new Shell (display);
> GridLayout gl = new GridLayout(1, true);
> shell.setLayout(gl);
> final Table table = new Table (shell, SWT.MULTI | SWT.CHECK | SWT.BORDER | 
> SWT.V_SCROLL | SWT.H_SCROLL);
> table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
>
> for (int i=0; i<5; i++) {
> TableItem item = new TableItem (table, SWT.NONE);
> item.setText("12345678901234567890123456789");
> }
>
> Thread thread = new Thread () {
> public void run () {
> for (int i=0; i<20000; i++) {
> if (table.isDisposed ()) return;
> display.asyncExec (new Runnable () {
> public void run () {
> if (table.isDisposed ()) return;
>
> if(table.getItemCount() == 25) {
> FileDialog fd = new FileDialog(shell, SWT.OPEN);
> fd.open();
> }
>
> TableItem item = new TableItem (table, SWT.NONE);
> item.setText("12345678901234567890123456789");
> }
> });
> }
> }
> };
> thread.start();
>
> table.setSize(table.computeSize(SWT.DEFAULT, 200));
> shell.pack ();
> shell.open ();
>
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }