Skip to content

fix memory leaks in FRED and QtFRED - #7784

Merged
BMagnu merged 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/fred_leaks
Sep 21, 2026
Merged

BMagnu merged 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
@notimaginative

Copy link
Copy Markdown
Contributor

Been over this a few times over the past couple of days without noticing any particular issue. But I'm really not familiar enough with FRED/QtFRED (nor MFC/Qt) to say that the changes are proper.

@github-project-automation github-project-automation Bot moved this from Work In Progress (PRs) to In Review (PRs) in qtFRED2 Sep 21, 2026
@BMagnu
BMagnu merged commit 09fc705 into scp-fs2open:master Sep 21, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from In Review (PRs) to Done in qtFRED2 Sep 21, 2026
@Goober5000
Goober5000 deleted the fix/fred_leaks branch September 21, 2026 04:40
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: Done

Development

Successfully merging this pull request may close these issues.

3 participants