Skip to content

Fix memory leak found by copilot#3728

Merged
ann0see merged 2 commits into
jamulussoftware:mainfrom
ann0see:bug/copilotMemleakFix
Jun 10, 2026
Merged

Fix memory leak found by copilot#3728
ann0see merged 2 commits into
jamulussoftware:mainfrom
ann0see:bug/copilotMemleakFix

Conversation

@ann0see

@ann0see ann0see commented Jun 6, 2026

Copy link
Copy Markdown
Member

Short description of changes

Tries to fix memory leak found by copilot: See: #3702 This should be valiated. I checked that the audio alerts still play - and it seems to work, but further investigation is still needed. I experienced hearing an audio-alert twice - but that may just be due to my testing mythology.

CHANGELOG: Bugfix: Fix memory leak for audio alerts

Context: Fixes an issue?

See: #3702

Does this change need documentation? What needs to be documented and how?

No

Status of this Pull Request

Needs review and testing.

What is missing until this pull request can be merged?

Testing

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see ann0see force-pushed the bug/copilotMemleakFix branch from ff14307 to fe225f2 Compare June 6, 2026 20:07
@ann0see ann0see added this to the Release 4.0.0 milestone Jun 6, 2026
@ann0see ann0see added this to Tracking Jun 6, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Jun 6, 2026
@ann0see ann0see moved this from Triage to Waiting on Team in Tracking Jun 6, 2026
@ann0see ann0see requested a review from pljones June 6, 2026 20:09
Comment thread src/clientdlg.cpp Outdated

@softins softins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good. I've built and tried it, and verified by adding debug messages that the deleteLater() is being called when it should be in each case.

Comment thread src/clientdlg.cpp Outdated
if ( pSettings->bEnableAudioAlerts && iNewNumClients > iClients )
{
QSoundEffect* sf = new QSoundEffect();
QSoundEffect* sf = new QSoundEffect ( this );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I'd feel happier with this duplicated code factored out into a method. That way any future sound effects can be played by the same code, without having to write another copy.

Co-authored-by: softins <softins@users.noreply.github.com>
See: jamulussoftware#3702
@ann0see ann0see force-pushed the bug/copilotMemleakFix branch from fe225f2 to c408a02 Compare June 9, 2026 20:43
@ann0see ann0see requested review from pljones and softins June 9, 2026 20:44
@ann0see

ann0see commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Weird. It compiled for me locally.

@softins

softins commented Jun 9, 2026

Copy link
Copy Markdown
Member

Weird. It compiled for me locally.

I think it might be better to put PlayAudioAlert() in clientdlg instead of moving it to util.

@softins

softins commented Jun 9, 2026

Copy link
Copy Markdown
Member

Weird. It compiled for me locally.

I think it might be better to put PlayAudioAlert() in clientdlg instead of moving it to util.

Yes, you definitely should, as it is specific to the client GUI.

The Linux build in CI builds both a GUI and a headless version, and it is the headless one that is failing, because the include paths for QtWidgets, QtMultimedia and QtGUI are not in the headless build.

If you want to keep PlayAudioAlert() in util, you need to put the #include <QSoundEffect> within the #ifndef HEADLESS section with the other GUI includes, and also protect the declaration and definition of PlayAudioAlert() with #ifndef HEADLESS too. I think it's easier and more logical just to move it back to clientdlg.

@softins

softins commented Jun 9, 2026

Copy link
Copy Markdown
Member

I suppose if you might want to use it in serverdlg too, you could keep it in util, and just do the #ifndef thing.

@softins

softins commented Jun 9, 2026

Copy link
Copy Markdown
Member

I just pushed a commit to try it.

@ann0see

ann0see commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Thanks. The idea was that one could use audio alerts everywhere. So util.* seemed the best fitting location.

@pljones

pljones commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Weird. It compiled for me locally.

I think it might be better to put PlayAudioAlert() in clientdlg instead of moving it to util.

Not in the graphical UI, if it's avoidable. I'd rather we had the assistive UI support separately, so it could be used even if the graphical UI was not in used. There's too much functional code there.

@softins

softins commented Jun 10, 2026

Copy link
Copy Markdown
Member

Not in the graphical UI, if it's avoidable. I'd rather we had the assistive UI support separately, so it could be used even if the graphical UI was not in used. There's too much functional code there.

It's ok, we've left it in util.*, but excluded for headless compilation, as QSoundEffect is a GUI-only module in Qt anyway.

I think this is ready to go in now.

@ann0see ann0see merged commit ae4898b into jamulussoftware:main Jun 10, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting on Team to Done in Tracking Jun 10, 2026
@ann0see ann0see deleted the bug/copilotMemleakFix branch June 10, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants