mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-11-26 06:00:17 +00:00
Fix a crash when BGMDevice's volume is changed.
I think that, because BGMStatusBarItem::initWithMenu was capturing a weak reference in a C++ lambda as a C++ reference, the C++ reference would be invalid when it was used. The fix to have the lambda capture by value instead. I'm not completely sure why builds from Xcode never crashed or why ASan didn't catch the bug. Maybe the stack memory was just never reused/invalidated with Xcode builds. (And I probably just don't understand how ASan works well enough.) Fixes #202.
This commit is contained in:
parent
26dd2ee1ab
commit
df9815a4be
1 changed files with 1 additions and 1 deletions
|
@ -84,7 +84,7 @@ static CGFloat const kVolumeIconAdditionalVerticalPadding = 0.075;
|
|||
|
||||
// Update the icon when BGMDevice's volume changes.
|
||||
BGMStatusBarItem* __weak weakSelf = self;
|
||||
volumeChangeListener = new BGMVolumeChangeListener(audioDevices.bgmDevice, [&] {
|
||||
volumeChangeListener = new BGMVolumeChangeListener(audioDevices.bgmDevice, [=] {
|
||||
[weakSelf bgmDeviceVolumeDidChange];
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue