Commit b983cdcf authored by Marinus Schraal's avatar Marinus Schraal

playlists: Fix Tracker criticals

An ordering issue in _static_playlist_query_cb resulted in critical
warnings being emitted. get_string was always called, regardless of a
result being available and the async operation being finished.
Only call get_string after next_finish returns with a result.

Closes: #251
parent 961ae87c
Pipeline #45500 passed with stages
in 6 minutes and 33 seconds
...@@ -285,23 +285,22 @@ class Playlists(GObject.GObject): ...@@ -285,23 +285,22 @@ class Playlists(GObject.GObject):
return return
def callback(cursor, res, final_query): def callback(cursor, res, final_query):
uri = cursor.get_string(0)[0] has_next = False
final_query += Query.add_song_to_playlist(playlist.ID, uri)
try: try:
has_next = cursor.next_finish(res) has_next = cursor.next_finish(res)
except GLib.Error as err: except GLib.Error as err:
logger.warning("Error: {}, {}".format(err.__class__, err)) logger.warning("Error: {}, {}".format(err.__class__, err))
has_next = False
# Only perform the update when the cursor reached the end # Only perform the update when the cursor reached the end
if has_next: if has_next:
cursor.next_async(None, callback, final_query) uri = cursor.get_string(0)[0]
return final_query += Query.add_song_to_playlist(playlist.ID, uri)
self.tracker.update_blank_async( cursor.next_async(None, callback, final_query)
final_query, GLib.PRIORITY_LOW, None, else:
self._static_playlist_update_finished, playlist) self.tracker.update_blank_async(
final_query, GLib.PRIORITY_LOW, None,
self._static_playlist_update_finished, playlist)
# Asynchronously form the playlist's final query # Asynchronously form the playlist's final query
cursor.next_async(None, callback, final_query) cursor.next_async(None, callback, final_query)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment