Nils пре 3 месеци
2 измењених фајлова са 13 додато и 1 уклоњено
  1. +12
  2. +1

+ 12
- 1
template/engine/ Прегледај датотеку

@@ -61,6 +61,7 @@ class Score(Data):
self.tracks = [] #see docstring
self.tempoMap = TempoMap(parentData = self)
self._tracksFailedLookup = []

def _template_processAfterInit(self): #needs a different name because there is an inherited class with the same method.
"""Call this after either init or instanceFromSerializedData"""
@@ -119,11 +120,21 @@ class Score(Data):
except Exception as e: #No Jack Meta Data or Error with ports.

def trackById(self, trackId:int):
"""Returns a track or None, if not found"""
for track in self.tracks:
if trackId == id(track):
return track
raise ValueError(f"Track {trackId} not found. Current Tracks: {[id(tr) for tr in self.tracks]}")
#Previously this crashed with a ValueError. However, after a rare bug that a gui widget focussed out because a track was deleted and then tried to send its value to the engine we realize that this lookup can gracefully return None.
#Nothing will break: Functions that are not aware yet, that None is an option will crash when they try to access None as a track object. For this case we present the following logger error:
if not trackId in self._tracksFailedLookup:
logger.error(f"Track {trackId} not found. Current Tracks: {[id(tr) for tr in self.tracks]}")
self._tracksFailedLookup.append(trackId) #prevent multiple error messages for the same track in a row.
return None
#raise ValueError(f"Track {trackId} not found. Current Tracks: {[id(tr) for tr in self.tracks]}")

#Save / Load / Export

+ 1
- 0
template/qtgui/ Прегледај датотеку

@@ -57,6 +57,7 @@ api.session.eventLoop = EventLoop()

#Setup the translator before classes are set up. Otherwise we can't use non-template translation.
#to test use LANGUAGE=de_DE.UTF-8 . not LANG=
#Language variants like de_AT.UTF-8 will be detected automatically and will result in Qt language detection as "German"
language = QtCore.QLocale().languageToString(QtCore.QLocale().language())"{}: Language set to {}".format(METADATA["name"], language))
if language in METADATA["supportedLanguages"]: