Skip to content

Commit

Permalink
gtkui: fix crash when drag-dropping files (regression from adding undo)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Mar 25, 2024
1 parent 76b765e commit a86ed4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions plugins/cocoaui/XIB/SplitViewMainWindow.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down
13 changes: 7 additions & 6 deletions plugins/gtkui/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ gtkpl_add_fm_dropped_files (ddb_playlist_t *plt, DB_playItem_t *drop_before, con
after = deadbeef->pl_get_prev (drop_before, PL_MAIN);
}
else {
after = deadbeef->pl_get_last (PL_MAIN);
after = deadbeef->plt_get_last (plt, PL_MAIN);
}
const uint8_t *p = (const uint8_t*)ptr;
while (*p) {
Expand Down Expand Up @@ -351,14 +351,15 @@ gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) {


dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ddb_playItem_t *first = gtkpl_add_fm_dropped_files (plt, data->drop_before, data->mem, data->length);
ddb_playItem_t *first = gtkpl_add_fm_dropped_files (plt, NULL, data->mem, data->length);

gtkui_dispatch_on_main(^{
ddb_playItem_t *tail = deadbeef->plt_get_tail_item(plt_curr, PL_MAIN);
ddb_undo->set_action_name (_("Drag & Drop"));
deadbeef->plt_move_all_items (plt_curr, plt, tail);
if (tail != NULL) {
deadbeef->pl_item_unref (tail);

ddb_playItem_t *after = deadbeef->pl_get_prev(data->drop_before, PL_MAIN);
deadbeef->plt_move_all_items (plt_curr, plt, after);
if (after != NULL) {
deadbeef->pl_item_unref (after);
}

deadbeef->plt_save_config (plt_curr);
Expand Down
4 changes: 4 additions & 0 deletions src/playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3791,6 +3791,10 @@ void
plt_move_all_items (playlist_t *to, playlist_t *from, playItem_t *insert_after) {
LOCK;
playItem_t *it = from->head[PL_MAIN];
if (it == NULL) {
UNLOCK;
return;
}
pl_item_ref(it);
ddb_undobuffer_group_begin (ddb_undomanager_get_buffer (ddb_undomanager_shared ()));
while (it != NULL) {
Expand Down

0 comments on commit a86ed4f

Please sign in to comment.