mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-03 21:29:27 +00:00
[Problem] InitializeUIValues always calls itself -> fix DriveLetterComboBoxSelectionChanged
#623
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?@Deterous commented on GitHub (Oct 10, 2023):
Sorry for the obtuse issue, I managed to nail down where my issue was occurring and wanted to make it clear what was happening.
Here's an example of what happens when you press the 'Scan for discs' button (which calls

InitializeUIValues):This showcases the issue:
InitializeUIValuesis run without a valid drive (when called by the drive combo box), then properly completes the second time, after "Found 1 drives: D".@mnadareski commented on GitHub (Oct 10, 2023):
I will tackle this after the next release given that it is not a blocking issue.
@mnadareski commented on GitHub (Oct 11, 2023):
May be handled or partially handled by
81742a4676@Deterous commented on GitHub (Oct 11, 2023):
Completely fixed by
81742a4