Fix another crash when BGMDevice's volume is changed.

Fixes the same issue as df9815a4be, but in
BGMOutputVolumeMenuItem instead of BGMStatusBarItem.

I think the problem was that it captured a weak reference in a C++
lambda, but it would capture by (C++) reference and when the reference
was used it would be referencing invalid memory. The fix to have the
lambda capture by value instead.

See #202.
This commit is contained in:
Kyle Neideck 2019-03-28 18:29:54 +11:00
parent 2939dbe28c
commit 503d1a92ec
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C

View file

@ -104,7 +104,7 @@ NSString* const __nonnull kGenericOutputDeviceName = @"Output Device";
// Register a listener that will update the slider when the user changes the volume or
// mutes/unmutes their audio.
BGMOutputVolumeMenuItem* __weak weakSelf = self;
volumeChangeListener = new BGMVolumeChangeListener(audioDevices.bgmDevice, [&] {
volumeChangeListener = new BGMVolumeChangeListener(audioDevices.bgmDevice, [=] {
[weakSelf updateVolumeSlider];
});
}