mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-03 21:29:27 +00:00
[Problem] InitializeUIValues always calls itself -> fix DriveLetterComboBoxSelectionChanged
#620
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Deterous on GitHub (Oct 10, 2023).
Originally assigned to: @mnadareski on GitHub.
Every time
InitializeUIValuesis called (except perhaps during init), the function calls itself.This is a side effect of
InitializeUIValuescallingPopulateDrives, which in turn runs:a8e783235c/MPF.Core/UI/ViewModels/MainViewModel.cs (L621)By creating the list of drives, the Drive Letter Combo Box changes, which triggers
DriveLetterComboBoxSelectionChanged, which in turn callsInitializeUIValuesagain:a8e783235c/MPF.UI.Core/Windows/MainWindow.xaml.cs (L339)This is an obvious unintended code execution, and also causes the log to mention that there are no valid drives, because
DriveLetterComboBoxSelectionChangedrunsInitializeUIValueswithout any drives. Fortunately, rescanDrives is set to false, or else this would be recursive :)Potential solution:
DriveLetterComboBoxSelectionChangedlogic can somehow be improved to ensure it is only called when the user changes the combo box, not the program itself?