Skip to content

Streamline memory allocation options and improve preset management#6330

Open
Glavo wants to merge 2 commits into
HMCL-dev:mainfrom
Glavo:fix-6307
Open

Streamline memory allocation options and improve preset management#6330
Glavo wants to merge 2 commits into
HMCL-dev:mainfrom
Glavo:fix-6307

Conversation

@Glavo

@Glavo Glavo commented Jul 7, 2026

Copy link
Copy Markdown
Member

Fix #6307

@Glavo

Glavo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the game settings UI to dynamically track and update inherited settings when parent presets change, replacing global listeners on SettingsManager with parent-specific property listeners. It also updates how parent presets are retrieved and introduces a dynamic description for the memory allocation sublist. Feedback on this PR highlights an issue where the collapsed memory sublist description may initially display incorrect information due to lazy loading of the sublist content. It is recommended to bind memorySelectedValue to the active setting's autoMemoryProperty using a weak listener to ensure the description is accurate from the start.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +430 to +432
memorySelectedValue.addListener((observable, oldValue, newValue) ->
memorySublist.setDescription(getMemoryAllocationDisplayName(newValue)));
memorySublist.setDescription(getMemoryAllocationDisplayName(memorySelectedValue.get()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since ComponentSublist content is loaded lazily via a Supplier, the memoryItem and its listener that updates memorySelectedValue are not initialized until the sublist is expanded. Consequently, the collapsed sublist description will initially display the default value (settings.memory.auto_allocate) even if the active setting is configured for manual memory allocation.[361, 387, 430]\n\nTo ensure the description is always accurate from the start, we should also bind memorySelectedValue to the active setting's autoMemoryProperty using a weak listener.

            memorySelectedValue.addListener((observable, oldValue, newValue) ->
                    memorySublist.setDescription(getMemoryAllocationDisplayName(newValue)));
            InvalidationListener memoryDescriptionListener = observable -> {
                S setting = currentSetting.get();
                if (setting != null) {
                    memorySelectedValue.set(IndependentSettingBinder.getEffectiveValue(
                            setting,
                            GameSettings::autoMemoryProperty,
                            this::getEffectiveParentGameSettings));
                }
            };
            InvalidationListener weakMemoryDescriptionListener = holder.weak(memoryDescriptionListener);
            currentSetting.addListener((observable, oldValue, newValue) -> {
                if (oldValue != null) {
                    oldValue.autoMemoryProperty().removeListener(weakMemoryDescriptionListener);
                }
                if (newValue != null) {
                    newValue.autoMemoryProperty().addListener(weakMemoryDescriptionListener);
                }
                memoryDescriptionListener.invalidated(newValue);
            });
            S initialSetting = currentSetting.get();
            if (initialSetting != null) {
                initialSetting.autoMemoryProperty().addListener(weakMemoryDescriptionListener);
            }
            memoryDescriptionListener.invalidated(initialSetting);

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] 内存分配显示类型异常

1 participant