Skip to content

bugfix(gui): Free push button data the headless dummy window cannot keep - #3480

Open
tintinhamans wants to merge 1 commit into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/pushbutton-data-guard
Open

tintinhamans wants to merge 1 commit into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/pushbutton-data-guard

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 11, 2026 •

Copy link
Copy Markdown

The push-button setters allocate PushButtonData when a window has none. The headless dummy always returns null for user data, so repeated calls keep allocating data that cannot be retrieved or cleaned up. The debug leak report of a headless replay grows by six blocks per match from this alone.

getNewPushButtonData now checks TheWindowManager->isDummy() and returns null before allocating. The setters share a helper that handles that result, without the old store/read-back/delete check.

Normal buttons and the USER cameo window still get their data and cleanup as before. Headless keeps its existing dummy windows, without loading WND files or enabling UI callbacks.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da5dd4f0-c4d6-47cb-9141-0a8ff8d9cd23
📥 Commits

Reviewing files that changed from the base of the PR and between fdd8b0a and 55bd6b8.

📒 Files selected for processing: 2
  • Core/GameEngine/Include/GameClient/GameWindowManager.h
  • Core/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The window manager now reports whether it is a dummy. Push-button data creation returns null in dummy mode. Five setters use a shared helper and return without updating fields when data is unavailable.

Changes

Dummy-mode push-button data handling

Layer / File(s) Summary
Dummy window manager state
Core/GameEngine/Include/GameClient/GameWindowManager.h
GameWindowManager::isDummy() returns false. GameWindowManagerDummy::isDummy() returns true.
Push-button data creation and setter updates
Core/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp
getNewPushButtonData returns nullptr when the window manager is in dummy mode. A shared helper retrieves existing button data or creates and attaches it. The border, clock, inverse-clock, overlay-image, and user-data setters return without updating fields if the helper returns nullptr.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: skyaero42

Merge Risk: ⚪ Minimal · up to 55bd6

Normal gameplay retains the Cameo veterancy overlay, and the headless-only data handling addresses the reported leak. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies a GUI bug fix for leaked push-button data in headless dummy windows.
Description check Passed The description accurately explains the headless-mode leak, identifies the affected behavior, and summarizes the implemented fix.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Prevents headless button setters from allocating PushButtonData that dummy windows cannot read back.

  • Headless push-button setters no longer allocate data their windows cannot keep.

Reviews (5) · Last reviewed commit: "fix(gui): Avoid allocating push button d..." · Reviewed by Greptile

@tintinhamans tintinhamans added Bug Something is not working right, typically is user facing Gen Relates to Generals ZH Relates to Zero Hour Memory Is memory related labels Oct 11, 2026
Comment thread Core/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/pushbutton-data-guard branch from a112357 to 90622b0 Compare October 13, 2026 08:02
@tintinhamans tintinhamans added the GUI For graphical user interface label Oct 13, 2026
void GadgetButtonDrawOverlayImage( GameWindow *g, const Image *image )
{
if( g == nullptr )
if( !isPushButtonWindow( g ) )

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This breaks the veterancy overlay on the unit portrait. CameoWindow in ControlBar.wnd is a USER window drawn with W3DGadgetPushButtonImageDraw, and ControlBar.cpp:2665 sets its overlay through GadgetButtonDrawOverlayImage, which now returns early. Could we fix the headless dummy window instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

right, the cameo gets one too and ControlBar frees it. moved the fix to the dummy window path instead, setters now drop the data when the window can’t keep it

@tintinhamans tintinhamans changed the title bugfix(gui): Only attach push button data to push button windows bugfix(gui): Free push button data the headless dummy window cannot keep Oct 14, 2026
@tintinhamans
tintinhamans force-pushed the arctic/fix/pushbutton-data-guard branch from 90622b0 to fdd8b0a Compare October 14, 2026 22:23
{
pData = getNewPushButtonData();
g->winSetUserData( pData );
// The headless dummy window does not keep user data

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I do not like that the user code needs to accomodate the special headless dummy implementation. Dummy should offer the same contract as the non-dummy implementation. Can we implement this differently?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

restoring the normal window lifecycle fixes it, but requires headless to load WND files and run the UI callbacks. did you have a smaller dummy-side fix in mind that avoids doing that?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

First idea of improvement is to return null in getNewPushButtonData if TheWindowManager->isDummy() returns true.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added isDummy() so it skips the allocation, and dropped the read-back check

@tintinhamans
tintinhamans marked this pull request as draft October 18, 2026 14:04
@tintinhamans
tintinhamans marked this pull request as ready for review October 18, 2026 14:19
@tintinhamans
tintinhamans force-pushed the arctic/fix/pushbutton-data-guard branch from fdd8b0a to 55bd6b8 Compare October 18, 2026 20:21
@tintinhamans
tintinhamans requested a review from xezon October 18, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals GUI For graphical user interface Memory Is memory related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants