File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ func load_ceol_song_safe() -> void:
144144
145145func _load_ceol_song_confirmed (path : String ) -> bool :
146146 var loaded_song : Song = SongLoader .load (path )
147- if not loaded_song :
147+ if not loaded_song || not loaded_song . is_valid_song () :
148148 Controller .update_status ("FAILED TO LOAD SONG" , Controller .StatusLevel .ERROR )
149149 return false
150150
@@ -298,7 +298,7 @@ func _import_song_confirmed(import_config: ImportMasterPopup.ImportConfig) -> vo
298298
299299func _import_mid_song (import_config : ImportMasterPopup .ImportConfig ) -> void :
300300 var imported_song := MidiImporter .import (import_config )
301- if not imported_song :
301+ if not imported_song || not imported_song . is_valid_song () :
302302 Controller .update_status ("FAILED TO IMPORT SONG" , Controller .StatusLevel .ERROR )
303303 return
304304
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ static func load(path: String) -> Song:
3030 if reader .get_version () == 3 :
3131 return _load_v3 (reader )
3232
33- printerr ("SongLoader: The song file at '%s ' has unsupported version %d , an empty song is created instead ." % [ path , reader .get_version () ])
34- return Song . create_default_song ()
33+ printerr ("SongLoader: The song file at '%s ' has unsupported version %d ." % [ path , reader .get_version () ])
34+ return null
3535
3636
3737# Original release; due to a bug it never saved the instrument volume.
Original file line number Diff line number Diff line change @@ -102,6 +102,17 @@ static func create_default_song() -> Song:
102102 return song
103103
104104
105+ func is_valid_song () -> bool :
106+ # A valid song must have at least one instrument and one pattern.
107+ # We automatically create one of each whenever the last one is
108+ # deleted. Loaded and imported songs are expected to have at least
109+ # one as well.
110+ if instruments .is_empty () || patterns .is_empty ():
111+ return false
112+
113+ return true
114+
115+
105116func get_safe_filename (extension : String = FILE_EXTENSION ) -> String :
106117 if filename .is_empty ():
107118 return "%s .%s " % [ FILE_DEFAULT_NAME , extension ]
You can’t perform that action at this time.
0 commit comments