From df599b6422fc27771e26c4dfbe85883b1eee91c3 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 26 Jan 2021 23:53:03 -0800 Subject: [PATCH] Studio/place marker: make sure place marker is not an empty string or nothing. Re #155. Mypy: make sure place marker is neither an empty string nor None because track locator expects a genuine string for search text. This also results in moving the conditionals around in place marker script. --- addon/appModules/splstudio/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addon/appModules/splstudio/__init__.py b/addon/appModules/splstudio/__init__.py index 9344f3f29..eeacb8290 100644 --- a/addon/appModules/splstudio/__init__.py +++ b/addon/appModules/splstudio/__init__.py @@ -2618,12 +2618,8 @@ def script_findPlaceMarker(self, gesture): # #81: no more custom message for place marker track, as the generic one will be enough for now. if self.canPerformPlaylistCommands() == self.SPLPlaylistNoErrors: # 21.03/20.09.6-LTS: guard against place marker filename becoming nothing. - if self.placeMarker in (None, ""): - # Nullify place marker if it holds incorrect data. - self.placeMarker = None - # Translators: Presented when no place marker is found. - ui.message(_("No place marker found")) - else: + # #155 (21.03): an extra check to make sure it is indeed a string. + if self.placeMarker is not None and self.placeMarker != "": obj = api.getFocusObject().parent.firstChild track = self._trackLocator(self.placeMarker, obj=obj, columns=[obj.indexOf("Filename")]) # 21.03/20.09.6-LTS: only do the following if a track is found. @@ -2635,6 +2631,11 @@ def script_findPlaceMarker(self, gesture): # 21.03/20.09.6-LTS: bogus place marker, so nullify it. self.placeMarker = None ui.message(_("No place marker found")) + else: + # Nullify place marker if it holds incorrect data. + self.placeMarker = None + # Translators: Presented when no place marker is found. + ui.message(_("No place marker found")) def script_metadataStreamingAnnouncer(self, gesture): # 8.0: Call the module-level function directly.