Skip to content

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Dec 23, 2025

resolves #4942

  • 将独立窗口中的弹窗从 JavaFX Alert 更改为 JFX 弹窗。
  • 导出游戏运行栈错误弹窗添加堆栈
image image 代码 by Gemini3 ,测试了一遍应该没多大问题

@3gf8jv4dv
Copy link
Contributor

maybe resolves #4942?

@Glavo
Copy link
Member

Glavo commented Dec 24, 2025

请解决代码和主线的冲突。

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes standalone window dialogs by replacing JavaFX Alert dialogs with custom JFX dialogs, improving consistency and adding stack traces to error messages in the game runtime export functionality.

  • Centralized dialog management through a new DialogUtils utility class
  • Replaced JavaFX Alert with MessageDialogPane in LogWindow and GameCrashWindow
  • Enhanced error messages by including stack traces for export failures

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
DialogUtils.java New utility class that centralizes dialog creation, display, and lifecycle management for both Decorator-based and StackPane-based dialogs
DecoratorController.java Refactored to delegate dialog operations to DialogUtils, simplifying dialog handling code and removing duplicate logic
LogWindow.java Replaced JavaFX Alert dialogs with MessageDialogPane; added StackPane container to support JFX dialogs; enhanced error messages with stack traces
GameCrashWindow.java Replaced JavaFX Alert dialogs with MessageDialogPane; added StackPane container to support JFX dialogs; enhanced error messages with stack traces

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

getSkinnable().stackPane.getChildren().setAll(vbox);
getChildren().setAll(getSkinnable().stackPane);


Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra blank line here. Only one blank line should be used for consistency with the rest of the codebase.

Suggested change

Copilot uses AI. Check for mistakes.
StackPane container = dialog.getDialogContainer();
if (container != null) {
container.getProperties().remove(PROPERTY_DIALOG_INSTANCE);
container.getProperties().remove(PROPERTY_DIALOG_PANE_INSTANCE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没有清理 PROPERTY_PARENT_PANE_REFPROPERTY_PARENT_DIALOG_REF

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +126 to +128
container.getProperties().remove(PROPERTY_PARENT_DIALOG_REF);
container.getProperties().remove(PROPERTY_PARENT_PANE_REF);
}
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When closing the last dialog, the properties PROPERTY_PARENT_DIALOG_REF and PROPERTY_PARENT_PANE_REF should be removed from the content node's properties, not from the container's properties. These properties were set on the content node at lines 75-76. This could lead to memory leaks as references to the dialog and pane would remain in the content node's properties even after the dialog is closed.

Suggested change
container.getProperties().remove(PROPERTY_PARENT_DIALOG_REF);
container.getProperties().remove(PROPERTY_PARENT_PANE_REF);
}
}
content.getProperties().remove(PROPERTY_PARENT_DIALOG_REF);
content.getProperties().remove(PROPERTY_PARENT_PANE_REF);

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +43
public static void show(Decorator decorator, Node content) {
if (decorator.getDrawerWrapper() == null) {
Platform.runLater(() -> show(decorator, content));
return;
}

show(decorator.getDrawerWrapper(), content, (dialog) -> {
JFXDialogPane pane = (JFXDialogPane) dialog.getContent();
decorator.capableDraggingWindow(dialog);
decorator.forbidDraggingWindow(pane);
dialog.setDialogContainer(decorator.getDrawerWrapper());
});
}
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original dialog implementation disabled the navigator when a dialog was shown and re-enabled it when all dialogs were closed. This behavior is missing in the new DialogUtils implementation. When showing dialogs in the Decorator context, the navigator should be disabled to prevent navigation while a dialog is open, and re-enabled when the last dialog is closed.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,138 @@
package org.jackhuang.hmcl.ui;
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is missing the standard license header that all other files in the project have. The header should include the GPL-3.0 license notice, copyright information, and project name "Hello Minecraft! Launcher".

Copilot uses AI. Check for mistakes.
Comment on lines +129 to +131
} else {
pane.pop(content);
}
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When popping a dialog that is not the last one, the content node's properties (PROPERTY_PARENT_PANE_REF and PROPERTY_PARENT_DIALOG_REF) should be cleaned up to prevent potential memory leaks. These properties were set on the content at lines 75-76.

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit fb942d1 into HMCL-dev:main Jan 2, 2026
2 checks passed
@CiiLu CiiLu deleted the dialogggggggggggg branch January 2, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 日志窗口:点击「导出」时出现的消息提示框相关问题

3 participants