-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FileDialog & DirectoryDialog hang after closing them with opened menu
`gtk_file_chooser_native_new handle()` should be dereferenced after use as proposed in https://docs.gtk.org/gtk3/class.FileChooserNative.html. Otherwise `gtk_native_dialog_run()` seem to continue to run (probably because the opened menu still references the dialog), with the effect that: `the recursive main loop gives the effect of a modal dialog (it prevents the user from interacting with other windows in the same window group while the dialog is run)`. See https://docs.gtk.org/gtk3/method.NativeDialog.run.html Fixes #1062
- Loading branch information
1 parent
bd900fb
commit d2bb303
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Issue1062_FileChooserNativeDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Andrey Loskutov (loskutov@gmx.de) and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Andrey Loskutov (loskutov@gmx.de) - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swt.tests.gtk.snippets; | ||
|
||
/* | ||
* A handy snippet to test hanging File/Directory dialogs | ||
*/ | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionAdapter; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.layout.FillLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.DirectoryDialog; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.swt.widgets.FileDialog; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
public class Issue1062_FileChooserNativeDialog { | ||
|
||
public static void main(String[] args) { | ||
Display display = new Display(); | ||
Shell shell = new Shell(display); | ||
shell.setText("Issue1062_FileChooserNativeDialog"); | ||
shell.setLayout(new FillLayout(SWT.VERTICAL)); | ||
Label label = new Label(shell, SWT.WRAP); | ||
label.setText("Click to open dialog, then right click on some file to open a menu and after that close dialog." | ||
+ " The shell should not 'hang' after closing dialogs."); | ||
|
||
Button button = new Button(shell, 0); | ||
button.setText("Open File Dialog"); | ||
button.addSelectionListener(new SelectionAdapter() { | ||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
FileDialog dialog = new FileDialog(shell, SWT.OPEN); | ||
dialog.setText("Right click to open a menu and after that try to close dialog"); | ||
String string = dialog.open(); | ||
System.out.println("Selected: " + string); | ||
} | ||
}); | ||
|
||
button = new Button(shell, 0); | ||
button.setText("Open Directory Dialog"); | ||
button.addSelectionListener(new SelectionAdapter() { | ||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN); | ||
dialog.setText("Right click to open a menu and after that try to close dialog"); | ||
String string = dialog.open(); | ||
System.out.println("Selected: " + string); | ||
} | ||
}); | ||
|
||
shell.setSize(400, 200); | ||
shell.open(); | ||
while (!shell.isDisposed()) { | ||
if (!display.readAndDispatch()) | ||
display.sleep(); | ||
} | ||
display.dispose(); | ||
} | ||
|
||
} |