[macOS] Delay when closing dialog

未关闭
#3,718 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java, macos

调研方向

The payload contains only the reproduction snippet, with no source files named. Start by running the snippet on macOS, then find where Display.readAndDispatch() and the Cocoa event loop handle closing a dialog. The bug is confirmed when the dialog stays open during Thread.sleep(4000), and the fix is done when it closes immediately as it does on Windows and Linux.

由索引模型根据 Issue 内容生成。

描述

  • All versions of SWT and JFace
  • macOS 15, 26 or 27
  • Java 25 Temurin
  • This problem has always existed

There can be a delay when closing a Dialog (JFace or SWT) on Mac if it's followed by a long running task. This delay does not occur on Windows or Linux where the dialog is closed immediately.

Run the Snippet. On Windows or Linux the dialog or message box closes immediately. On Mac the dialog only closes when the long running task completes.

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class DialogCloseDelay {

    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setText("Dialog Test");
        shell.setLayout(new FillLayout());
        shell.setSize(450, 250);
        shell.open();

        // Same behavior on JFace Dialog or SWT Dialog (MessageBox)
        boolean useDialog = true;
        if(useDialog) {
            Dialog dialog = new Dialog(shell) {};
            dialog.open();
        }
        else {
            MessageBox box = new MessageBox(shell);
            box.open();
        }
        
        // Uncomment this to unfreeze it
        // shell.getDisplay().readAndDispatch();

        // Long running task
        try {
            Thread.sleep(4000);
        }
        catch(InterruptedException e) {}

        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }
        
        display.dispose();
    }
}

If the following line in the Snippet is uncommented there is no freeze:

shell.getDisplay().readAndDispatch();
主要语言
Java
星标
202
派生
206
平均合并
1 天 17 小时
30 天内合并 PR
109

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-platform/eclipse.platform.swt 的其他 Issue

查看 eclipse-platform/eclipse.platform.swt 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。