| Summary: | Timer does not run when FileDialog is open | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Silenio Quarti <Silenio_Quarti> | ||||||
| Component: | SWT | Assignee: | Silenio Quarti <Silenio_Quarti> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | skovatch | ||||||
| Version: | 3.6 | Flags: | skovatch:
review+
|
||||||
| Target Milestone: | 3.6 RC1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Mac OS X | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 166894 [details]
partial fix
This patch fixes this testcase, but not the previous one. Not sure why.
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class PRxx {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
display.timerExec(100, new Runnable() {
public void run() {
System.out.println("timer");
display.timerExec(100, this);
}
});
shell.pack();
shell.open();
shell.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(shell, SWT.NONE);
dialog.open();
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
The title is a bit misleading. With your patch, the timer is running, but the Runnable isn't executing because allowTimers is always false. The only place that sets it to true is Display.sleep(). NSOpenPanel runs its own loop in NSModalPanelRunLoopMode, but our sleep() isn't being called. We need both your patch plus we need to initialize allowTimers and runAsyncMessages to true. I'm not sure what problem you were seeing that forced the need for allowTimers in the first place. Maybe because the timers weren't being registered in all run loop modes? Your patch fixes the second case because the readAndDispatch loop is running when the MouseDown event fires, so allowTimers gets set to true when sleep() exits. Created attachment 166955 [details]
fix
Got it. The carbon code initializes it to true as well.
The allowTimers flags is needed to avoid timers running from Display.sleep().
Looks good. +1. Removing Security_Advisories flag. I am not sure how it got checked. Fixed > 20100504 |
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class PRxx { public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); display.timerExec(100, new Runnable() { public void run() { System.out.println("timer"); display.timerExec(100, this); } }); shell.pack(); shell.open(); FileDialog dialog = new FileDialog(shell, SWT.NONE); dialog.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }