Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Record Options Crash After Changing Theme #957

Merged

Conversation

complexlogic
Copy link
Contributor

Steps to reproduce the crash:

  1. Go to Options->Record
  2. Set the 'Assigned Player' for the current device to 'None'
  3. Go to Options->Themes
  4. Change to a different theme
  5. Go Options->Record

Stacktrace:

Exception class: EAccessViolation
Message: Access violation
  $0000000000542901  DRAW,  line 813 of screens/UScreenOptionsRecord.pas
  $000000000045FABA  DRAW,  line 379 of menu/UDisplay.pas
  $000000000047A432  MAINLOOP,  line 344 of base/UMain.pas
  $000000000047A1C6  MAIN,  line 269 of base/UMain.pas
  $00000000004074A7  main,  line 386 of ultrastardx.dpr

The crash occurs here because DeviceCfg.ChannelToPlayerMap is nil.

The reason is that changing the theme triggers a reloading of the config.ini file. In TIni.LoadInputDeviceCfg, the channel to player map is set to length zero by default, unless defined in the config.ini. Later, TAudioInputProcessor.UpdateInputDeviceConfig sets its length to the max number of channels supported by the audio device, which is at least 1. This ensures that the array will not be nil.

In summary, initializing the device config used in the record options is a two step process:

  1. TIni.LoadInputDeviceCfg: Read settings from config.ini into device config
  2. TAudioInputProcessor.UpdateInputDeviceConfig: Fill in the device config with information from actual device

After changing the theme, the current code is only doing 1 above. So, now a call is added to TAudioInputProcessor.UpdateInputDeviceConfig which fully initializes the device config and fixes the crash.

Copy link
Member

@barbeque-squared barbeque-squared left a comment

Choose a reason for hiding this comment

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

I'm sure I had this happen a few times over the years to me, and seen it happen to other people as well, but nobody knew what was causing it. Thanks for the contribution!

@barbeque-squared barbeque-squared merged commit be78eb3 into UltraStar-Deluxe:master Feb 5, 2025
5 checks passed
@complexlogic complexlogic deleted the record_options_crash branch February 5, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants