From 2752f8fb92a11a00992bf0f8720588512b84138e Mon Sep 17 00:00:00 2001 From: Oleksiy Yakovenko Date: Sat, 2 Nov 2024 21:28:40 +0100 Subject: [PATCH] plt_add_files_begin/end called on the current playlist, instead of the temporary one, to ensure correct functioning of autosort --- plugins/cocoaui/AppDelegate.m | 15 ++++++++------- .../cocoaui/Playlist/PlaylistViewController.m | 4 ++-- plugins/gtkui/fileman.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/plugins/cocoaui/AppDelegate.m b/plugins/cocoaui/AppDelegate.m index 853840b50d..926a0fb231 100644 --- a/plugins/cocoaui/AppDelegate.m +++ b/plugins/cocoaui/AppDelegate.m @@ -449,7 +449,7 @@ - (void)openFiles:(BOOL)clear play:(BOOL)play { deadbeef->plt_clear(plt_curr); deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0); } - if (!deadbeef->plt_add_files_begin (plt, 0)) { + if (!deadbeef->plt_add_files_begin (plt_curr, 0)) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ for (NSUInteger i = 0; i < files.count; i++) { NSString* fileName = [files[i] path]; @@ -469,7 +469,7 @@ - (void)openFiles:(BOOL)clear play:(BOOL)play { deadbeef->pl_item_unref (tail); } deadbeef->pl_save_current(); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); @@ -479,7 +479,7 @@ - (void)openFiles:(BOOL)clear play:(BOOL)play { }); } else { - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); } @@ -554,7 +554,7 @@ - (IBAction)addLocationAction:(id)sender { ddb_playlist_t *plt = deadbeef->plt_alloc ("add-location"); ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); - if (!deadbeef->plt_add_files_begin (plt, 0)) { + if (!deadbeef->plt_add_files_begin (plt_curr, 0)) { dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(aQueue, ^{ DB_playItem_t *tail = deadbeef->plt_get_last (plt, PL_MAIN); @@ -567,7 +567,7 @@ - (IBAction)addLocationAction:(id)sender { dispatch_async(dispatch_get_main_queue(), ^{ ddb_undo->set_action_name ("Add Location"); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); }); @@ -873,19 +873,20 @@ - (IBAction)loadPlaylistAction:(id)sender { ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); deadbeef->plt_clear (plt_curr); deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0); - if (!deadbeef->plt_add_files_begin (plt, 0)) { + if (!deadbeef->plt_add_files_begin (plt_curr, 0)) { int abort = 0; deadbeef->plt_load2 (0, plt, NULL, fname.UTF8String, &abort, NULL, NULL); if (!abort) { dispatch_async(dispatch_get_main_queue(), ^{ deadbeef->plt_move_all_items(plt_curr, plt, NULL); deadbeef->plt_save_config (plt); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); }); } else { + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); } diff --git a/plugins/cocoaui/Playlist/PlaylistViewController.m b/plugins/cocoaui/Playlist/PlaylistViewController.m index 9652849a96..ca53e02a3a 100644 --- a/plugins/cocoaui/Playlist/PlaylistViewController.m +++ b/plugins/cocoaui/Playlist/PlaylistViewController.m @@ -1370,7 +1370,7 @@ - (void)dropItems:(int)from_playlist before:(DdbListviewRow_t)before indices:(ui -(void)externalDropItems:(NSArray *)paths after:(DdbListviewRow_t)_after completionBlock:(nonnull void (^) (void))completionBlock { ddb_playlist_t *plt = deadbeef->plt_alloc("drag-drop-playlist"); ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); - if (!deadbeef->plt_add_files_begin (plt, 0)) { + if (!deadbeef->plt_add_files_begin (plt_curr, 0)) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ DB_playItem_t *first = NULL; DB_playItem_t *after = NULL; @@ -1407,7 +1407,7 @@ -(void)externalDropItems:(NSArray *)paths after:(DdbListviewRow_t)_after comple if (after) { deadbeef->pl_item_unref (after); } - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); if (abort) { deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index d4d8d95c5f..803b434e80 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -78,7 +78,7 @@ gtkui_add_dirs (GSList *lst) { ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); ddb_playlist_t *plt = deadbeef->plt_alloc ("add-dirs"); - if (deadbeef->plt_add_files_begin (plt, 0) < 0) { + if (deadbeef->plt_add_files_begin (plt_curr, 0) < 0) { deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); g_slist_free (lst); @@ -99,7 +99,7 @@ gtkui_add_dirs (GSList *lst) { } deadbeef->plt_save_config (plt_curr); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt_curr); deadbeef->plt_unref (plt); g_slist_free (lst); @@ -112,7 +112,7 @@ gtkui_add_files (struct _GSList *lst) { ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); ddb_playlist_t *plt = deadbeef->plt_alloc ("add-files"); - if (deadbeef->plt_add_files_begin (plt, 0) < 0) { + if (deadbeef->plt_add_files_begin (plt_curr, 0) < 0) { g_slist_free (lst); deadbeef->plt_unref (plt_curr); deadbeef->plt_unref (plt); @@ -131,7 +131,7 @@ gtkui_add_files (struct _GSList *lst) { } deadbeef->plt_save_config (plt_curr); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); deadbeef->plt_unref (plt_curr); deadbeef->plt_unref (plt); }); @@ -154,7 +154,7 @@ gtkui_add_location (const char *path, const char *custom_title) { ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); ddb_playlist_t *plt = deadbeef->plt_alloc ("add-location"); - if (deadbeef->plt_add_files_begin (plt, 0) < 0) { + if (deadbeef->plt_add_files_begin (plt_curr, 0) < 0) { deadbeef->plt_unref (plt); deadbeef->plt_unref (plt_curr); return; @@ -177,7 +177,7 @@ gtkui_add_location (const char *path, const char *custom_title) { } if (it == NULL) { - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); free (path_copy); free (custom_title_copy); @@ -202,7 +202,7 @@ gtkui_add_location (const char *path, const char *custom_title) { deadbeef->plt_save_config (plt_curr); ddb_undo->set_action_name (_("Add Location")); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); free (path_copy); free (custom_title_copy); @@ -338,7 +338,7 @@ gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) { ddb_playlist_t *plt = deadbeef->plt_alloc ("receive-drag-drop"); ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); - if (deadbeef->plt_add_files_begin (plt, 0) < 0) { + if (deadbeef->plt_add_files_begin (plt_curr, 0) < 0) { if (data->drop_before) { deadbeef->pl_item_unref (data->drop_before); } @@ -369,7 +369,7 @@ gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) { } deadbeef->plt_save_config (plt_curr); - deadbeef->plt_add_files_end (plt, 0); + deadbeef->plt_add_files_end (plt_curr, 0); set_dnd_cursor (first); if (first != NULL) {