Skip to content

fix memory leaks in FRED and QtFRED - #7784

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/fred_leaks
Open

Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/fred_leaks

Conversation

@Goober5000

@Goober5000 Goober5000 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Neither editor had a teardown to match FSO's game_shutdown(), so the engine data they set up was never freed. Add editor_free_engine_data() to free it, and call it from a new fred_shutdown() in FRED and from qtFRED's shutdown(), before the graphics system closes.

Also:

  • Delete FRED's modeless editors if they are still open at exit.
  • Make FRED's dialog tooltips and sexp tree image lists members, since
    they were leaked or depended on OnDestroy() being called.
  • Parent qtFRED's item models so they are deleted with their widgets.
  • Enable the CRT leak report in qtFRED, which previously had none.
  • In qtFRED, call shutdown() last in closeEvent(), since it destroys the
    window.
  • Make the preferences path and user SID strings function-level statics,
    so MFC's leak dump no longer reports them as leaks.

Depends on #7781; in draft until that is merged.

@Goober5000 Goober5000 added the fix A fix for bugs, not-a-bugs, and/or regressions. label Sep 13, 2026
@Goober5000 Goober5000 added qtfred A feature or issue related to qtFred. fred A feature or issue related to the FReespace EDitor (FRED) labels Sep 13, 2026
@github-project-automation github-project-automation Bot moved this to Work In Progress (PRs) in qtFRED2 Sep 13, 2026
Neither editor had a teardown to match FSO's game_shutdown(), so the engine
data they set up was never freed.  Add editor_free_engine_data() to free it,
and call it from a new fred_shutdown() in FRED and from qtFRED's shutdown(),
before the graphics system closes.

Also:
- Delete FRED's modeless editors if they are still open at exit.
- Make FRED's dialog tooltips and sexp tree image lists members, since
  they were leaked or depended on OnDestroy() being called.
- Parent qtFRED's item models so they are deleted with their widgets.
- Enable the CRT leak report in qtFRED, which previously had none.
- In qtFRED, call shutdown() last in closeEvent(), since it destroys the
  window.
- Make the preferences path and user SID strings function-level statics,
  so MFC's leak dump no longer reports them as leaks.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Goober5000
Goober5000 marked this pull request as ready for review September 15, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. fred A feature or issue related to the FReespace EDitor (FRED) qtfred A feature or issue related to qtFred.

Projects

Status: Work In Progress (PRs)

Development

Successfully merging this pull request may close these issues.

1 participant