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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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.31%. Comparing base (bca68e9) to head (484a5c0).
Report is 1 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.31%   30.31%           
- Complexity    15807    15810    +3     
=========================================
  Files          2886     2886           
  Lines        283126   283140   +14     
  Branches      49326    49326           
=========================================
+ Hits          85833    85844   +11     
+ Misses       191694   191691    -3     
- Partials       5599     5605    +6     

☔ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For New Dev Cycle This PR should be merged at the beginning of a dev cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants