Skip to content

Commit

Permalink
plt_add_files_begin/end called on the current playlist, instead of th…
Browse files Browse the repository at this point in the history
…e temporary one, to ensure correct functioning of autosort
  • Loading branch information
Oleksiy-Yakovenko committed Nov 2, 2024
1 parent 962fa50 commit 2752f8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
15 changes: 8 additions & 7 deletions plugins/cocoaui/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/cocoaui/Playlist/PlaylistViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions plugins/gtkui/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
});
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2752f8f

Please sign in to comment.