Skip to content

FileDialog on macOS Sequoia/Tahoe returns wrong extension (and appends it twice) #2566

@orionll

Description

@orionll

To Reproduce

  1. Run the following slightly modified Snippet 72:
import org.eclipse.swt.widgets.FileDialog;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class Main {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Snippet 72");
		shell.open();
		FileDialog dialog = new FileDialog(shell, SWT.SAVE);
		String[] filterNames = new String[] { "ABC (*.abcd)", "PNG (*.png)", "JPG (*.jpg)" };
		String[] filterExtensions = new String[] { "*.abcd", "*.png", "*.jpg" };
		dialog.setFilterNames(filterNames);
		dialog.setFilterExtensions(filterExtensions);
		dialog.setFileName("myfile");
		dialog.setOverwrite(true);
		System.out.println("Save to: " + dialog.open());
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
  1. When a macOS file dialog is shown, select the second file extension (i.e. *.png).
  2. Click Save

The program prints .../myfile.abcd.abcd.

Expected behavior
The program must have printed .../myfile.png instead.

Environment:
macOS Sequoia
macOS Tahoe

(older versions of macOS aren't affected)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions