Fix crashes when batch downloading
The callbacks from AdapterManager.batch_download_songs happen on a separate thread, which means any GTK-related functions must be avoided.
This commit is contained in:
@@ -465,13 +465,17 @@ class ArtistDetailPanel(Gtk.Box):
|
|||||||
def on_download_all_click(self, _):
|
def on_download_all_click(self, _):
|
||||||
AdapterManager.batch_download_songs(
|
AdapterManager.batch_download_songs(
|
||||||
self.get_artist_song_ids(),
|
self.get_artist_song_ids(),
|
||||||
before_download=lambda _: self.update_artist_view(
|
before_download=lambda _: GLib.idle_add(
|
||||||
self.artist_id,
|
lambda: self.update_artist_view(
|
||||||
order_token=self.update_order_token,
|
self.artist_id,
|
||||||
|
order_token=self.update_order_token,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
on_song_download_complete=lambda _: self.update_artist_view(
|
on_song_download_complete=lambda _: GLib.idle_add(
|
||||||
self.artist_id,
|
lambda: self.update_artist_view(
|
||||||
order_token=self.update_order_token,
|
self.artist_id,
|
||||||
|
order_token=self.update_order_token,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -440,7 +440,7 @@ class MusicDirectoryList(Gtk.Box):
|
|||||||
self.loading_indicator.hide()
|
self.loading_indicator.hide()
|
||||||
|
|
||||||
def on_download_state_change(self, _):
|
def on_download_state_change(self, _):
|
||||||
self.update()
|
GLib.idle_add(self.update)
|
||||||
|
|
||||||
# Create Element Helper Functions
|
# Create Element Helper Functions
|
||||||
# ==================================================================================
|
# ==================================================================================
|
||||||
|
@@ -206,7 +206,7 @@ class AlbumWithSongs(Gtk.Box):
|
|||||||
allow_deselect = False
|
allow_deselect = False
|
||||||
|
|
||||||
def on_download_state_change(song_id: str):
|
def on_download_state_change(song_id: str):
|
||||||
self.update_album_songs(self.album.id)
|
GLib.idle_add(lambda: self.update_album_songs(self.album.id))
|
||||||
|
|
||||||
# Use the new selection instead of the old one for calculating what
|
# Use the new selection instead of the old one for calculating what
|
||||||
# to do the right click on.
|
# to do the right click on.
|
||||||
@@ -238,8 +238,8 @@ class AlbumWithSongs(Gtk.Box):
|
|||||||
def on_download_all_click(self, btn: Any):
|
def on_download_all_click(self, btn: Any):
|
||||||
AdapterManager.batch_download_songs(
|
AdapterManager.batch_download_songs(
|
||||||
[x[-1] for x in self.album_song_store],
|
[x[-1] for x in self.album_song_store],
|
||||||
before_download=lambda _: self.update(),
|
before_download=lambda _: GLib.idle_add(self.update),
|
||||||
on_song_download_complete=lambda _: self.update(),
|
on_song_download_complete=lambda _: GLib.idle_add(self.update),
|
||||||
)
|
)
|
||||||
|
|
||||||
def play_btn_clicked(self, btn: Any):
|
def play_btn_clicked(self, btn: Any):
|
||||||
|
Reference in New Issue
Block a user