Skip to content

added dispose() on some dialogs (fix memory leaks) #6959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 8, 2025

Conversation

exeea
Copy link
Collaborator

@exeea exeea commented Apr 29, 2025

This PR fixes few memory leaks.
Added dispose() calls to:

  • CostDisplayDialog
  • WeightDisplayDialog
  • ASConversionInfoDialog
  • EntityReadoutDialog
  • ASStatsDialog
  • AutoResolveChanceDialog
  • SBFStatsDialog

those are dialogs that are spawned every time, never reused.

@Copilot Copilot AI review requested due to automatic review settings April 29, 2025 21:38
@exeea exeea requested a review from a team as a code owner April 29, 2025 21:38
Copy link
Contributor

@Copilot 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 adds dispose() calls via overriding cancelAction() in both dialog classes to ensure proper resource cleanup when a cancel action is triggered.

  • Overrides cancelAction() in WeightDisplayDialog to call dispose().
  • Overrides cancelAction() in CostDisplayDialog to call dispose().

Reviewed Changes

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

File Description
megamek/src/megamek/client/ui/dialogs/WeightDisplayDialog.java Added cancelAction() override that calls dispose() for proper resource cleanup.
megamek/src/megamek/client/ui/dialogs/CostDisplayDialog.java Added cancelAction() override that calls dispose() for proper resource cleanup.

@exeea exeea changed the title added dispose() on two dialogs added dispose() on some dialogs Apr 29, 2025
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 30.33%. Comparing base (e604a99) to head (1b7b3f8).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
...mek/client/ui/dialogs/AutoResolveChanceDialog.java 0.00% 3 Missing ⚠️
...amek/client/ui/dialogs/ASConversionInfoDialog.java 0.00% 2 Missing ⚠️
...k/src/megamek/client/ui/dialogs/ASStatsDialog.java 0.00% 2 Missing ⚠️
...c/megamek/client/ui/dialogs/CostDisplayDialog.java 0.00% 2 Missing ⚠️
...megamek/client/ui/dialogs/EntityReadoutDialog.java 0.00% 2 Missing ⚠️
.../src/megamek/client/ui/dialogs/SBFStatsDialog.java 0.00% 2 Missing ⚠️
...megamek/client/ui/dialogs/WeightDisplayDialog.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6959   +/-   ##
=========================================
  Coverage     30.32%   30.33%           
- Complexity    15859    15875   +16     
=========================================
  Files          2891     2891           
  Lines        283420   283434   +14     
  Branches      49329    49329           
=========================================
+ Hits          85958    85986   +28     
+ Misses       191837   191821   -16     
- Partials       5625     5627    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exeea exeea changed the title added dispose() on some dialogs added dispose() on some dialogs (fix memory leaks) Apr 29, 2025
@rjhancock rjhancock added the For New Dev Cycle This PR should be merged at the beginning of a dev cycle label Apr 29, 2025
@exeea exeea requested a review from rjhancock April 29, 2025 22:09
@Sleet01
Copy link
Collaborator

Sleet01 commented May 7, 2025

@exeea @rjhancock This is marked "For New Dev Cycle"; does that mean targeted at 0.50.07?

@Scoppio
Copy link
Collaborator

Scoppio commented May 7, 2025

I'd prefer to see those in this release, since its memory leak related.

@HammerGS
Copy link
Member

HammerGS commented May 7, 2025

I'm good with including it

@Sleet01 Sleet01 added GUI User Interface and removed For New Dev Cycle This PR should be merged at the beginning of a dev cycle labels May 7, 2025
Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@HammerGS HammerGS merged commit 3d276c7 into MegaMek:master May 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants