| Summary: | SWT.OPEN and SWT.SAVE prevent file access in the parent shell? | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Mohsen Saboorian <mohsens> | ||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | Felipe Heidrich <eclipse.felipe> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | lshanmug, remy.suen, Silenio_Quarti | ||||
| Version: | 3.5.1 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
|
Description
Mohsen Saboorian
Please attach code to reproduce the problem. The following works fine for me. I have the image 'test.jpg' directly in my project's root folder.
---------------
public static Image image;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (image != null) {
image.dispose();
}
}
});
shell.open();
display.timerExec(3000, new Runnable() {
@Override
public void run() {
FileDialog dialog = new FileDialog(shell);
display.asyncExec(new Runnable() {
@Override
public void run() {
image = new Image(display, "test.jpg");
shell.setImage(image);
}
});
dialog.open();
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
Remy, thanks for your test case. This causes again that FNFE. The parent shell can no longer re-paint when the dialog is open. So if I move the dialog, parent shell cannot redraw (seems that all event managers in that dialog are freezed). When I close the dialog the exception is thrown. Here is the stack trace: Exception in thread "main" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: i/o error (java.io.FileNotFoundException: test.jpg (The system cannot find the file specified))) at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800) at org.eclipse.swt.widgets.Shell.WM_ENTERIDLE(Shell.java:2100) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3803) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1565) at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528) at org.eclipse.swt.internal.win32.OS.GetOpenFileNameW(Native Method) at org.eclipse.swt.internal.win32.OS.GetOpenFileName(OS.java:2612) at org.eclipse.swt.widgets.FileDialog.open(FileDialog.java:387) at test.LoadFailureTest$2.run(LoadFailureTest.java:37) at org.eclipse.swt.widgets.Display.runTimer(Display.java:3886) at org.eclipse.swt.widgets.Display.messageProc(Display.java:3091) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2370) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420) at test.LoadFailureTest.main(LoadFailureTest.java:42) Caused by: org.eclipse.swt.SWTException: i/o error (java.io.FileNotFoundException: test.jpg (The system cannot find the file specified)) at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:159) at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:26) at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:377) at org.eclipse.swt.graphics.Image.<init>(Image.java:735) at test.LoadFailureTest$2$1.run(LoadFailureTest.java:33) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) ... 17 more Caused by: java.io.FileNotFoundException: test.jpg (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at java.io.FileInputStream.<init>(FileInputStream.java:66) at org.eclipse.swt.internal.Compatibility.newFileInputStream(Compatibility.java:182) at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:156) ... 23 more (In reply to comment #2) > This causes again that FNFE. This is very strange. I do not have this problem on Windows 7. Please zip your project and attach it to bugzilla. Created attachment 159122 [details]
Here is the full project with Java6 and SWT 3.6M5
(In reply to comment #4) > Created an attachment (id=159122) [details] > Here is the full project with Java6 and SWT 3.6M5 The project you provided me works fine. In this project the path you specify is "src/test.gif". However, your trace from comment 2 is looking for a "test.jpg" file? > In this project the path you specify is "src/test.gif". However, your trace
> from comment 2 is looking for a "test.jpg" file?
In my previous stack trace I ran your test case in my [large] project. Since you asked to create a new project, I created one, and replaced that jpeg with a smaller gif file. I believe you can reproduce it on Windows XP, but it's so strange that such an issue is not reported yet. I search bugzilla and found nothing related. If you can run the project on an XP machine, I can be sure that I'm not the only one who see this problem :)
I'll run this code tomorrow at my office computer to check if my Laptop is not alone.
(In reply to comment #6) > I believe you can reproduce it on Windows XP I can reproduce this on XP SP2. (In reply to comment #7) > (In reply to comment #6) > > I believe you can reproduce it on Windows XP > > I can reproduce this on XP SP2. Can you ask someone at Eclipse side if this is a dup or not? I couldn't find a duplicate of this bug. Just tried to see where java is looking for the file, its trying to find it inside the folder containing the file selected by the File dialog. Specifying the absolute path of the file works fine. (In reply to comment #9) > I couldn't find a duplicate of this bug. > Just tried to see where java is looking for the file, its trying to find it > inside the folder containing the file selected by the File dialog. Specifying > the absolute path of the file works fine. Great workaround. Thank you very much. This is bug in Windows. When OPENFILENAME is up it changes the current working dir to the dir in the view. We set the flag OFN_NOCHANGEDIR but it has no effective.
The change of the working dir can not be verified by Java (calling System.getProperty("user.dir")) but it can be verified using win32 call GetCurrentDirectory().
Calls to java io (new File("relativepath/doc.txt")) also fail.
This is a one-off bulk update. (The last one in the triage migration). Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process: https://wiki.eclipse.org/SWT/Devel/Triage See Bug 518478 for details. Tag for notification/mail filters: @TriageBulkUpdate This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |