Commit d08ed95
committed
Fix crash due to undefined MIDI name variable
In ec445fe, the variable song_midi wasn't initialized properly when the greeting window was disabled, causing the program to crash. It's now defined both on startup and in the reset code.
What caused this whole business is the fact that MIDI import happens in two steps: open_midi (parses all the info in the file) and import_midi (converts the data into note blocks after you've picked instruments, etc.) Before the latter occurs, all the song data is reset, which also resets the MIDI filename that was stored on the first step. That made it necessary to remove it from the reset script and, instead, reset the name on unusual places, like in the greeting window and in the call for creating a new song.
Applied solution:
The first variable, midifile, stores the name on the first step. Every reset copies its value to a second variable, song_midi, used only for display. midifile is then set to "". With that, song_midi holds the song name for that session and displays it properly. When a song is created or loaded, a reset will occur and "" will be copied into song_midi, effectively clearing the display.
This also fixes an unintended side effect of how the name was being handled: if you loaded a MIDI but clicked 'Cancel' in the MIDI settings window, the name would still be displayed in song info. To prevent that from happening, the first variable (midifile) is reset when the user clicks 'Cancel', to prevent it from being copied over to the display variable (song_midi) on the next reset.1 parent 292e718 commit d08ed95
File tree
7 files changed
+5
-7
lines changed- scripts
- control_create
- draw_window_greeting
- draw_window_midi_import
- load_song
- new_song
- open_midi
- reset
7 files changed
+5
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 89 | + | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
0 commit comments