Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Feb 2, 2024
1 parent 05eb6be commit 541593e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
6 changes: 6 additions & 0 deletions shared/undo/undobuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ ddb_undobuffer_has_operations(ddb_undobuffer_t *undobuffer) {

void
ddb_undobuffer_group_begin (ddb_undobuffer_t *undobuffer) {
if (undobuffer == NULL) {
return;
}
undobuffer->grouping = 1;
}

void
ddb_undobuffer_group_end (ddb_undobuffer_t *undobuffer) {
if (undobuffer == NULL) {
return;
}
undobuffer->grouping = 0;
}

Expand Down
28 changes: 16 additions & 12 deletions src/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,30 @@ plt_sort_v2 (playlist_t *plt, int iter, int id, const char *format, int order) {
if (plt->undo_enabled) {
pl_lock ();
int count = plt->count[PL_MAIN];
playItem_t **tracks = calloc (count, sizeof (playItem_t *));
int index = 0;
for (playItem_t *it = plt->head[PL_MAIN]; it != NULL; it = it->next[PL_MAIN]) {
tracks[index++] = it;
if (count != 0) {
playItem_t **tracks = calloc (count, sizeof (playItem_t *));
int index = 0;
for (playItem_t *it = plt->head[PL_MAIN]; it != NULL; it = it->next[PL_MAIN]) {
tracks[index++] = it;
}
undo_remove_items(undobuffer, plt, tracks, count);
free (tracks);
}
undo_remove_items(undobuffer, plt, tracks, count);
free (tracks);
}

plt_sort_internal (plt, iter, id, format, order, 1);

if (plt->undo_enabled) {
int count = plt->count[PL_MAIN];
playItem_t **tracks = calloc (count, sizeof (playItem_t *));
int index = 0;
for (playItem_t *it = plt->head[PL_MAIN]; it != NULL; it = it->next[PL_MAIN]) {
tracks[index++] = it;
if (count != 0) {
playItem_t **tracks = calloc (count, sizeof (playItem_t *));
int index = 0;
for (playItem_t *it = plt->head[PL_MAIN]; it != NULL; it = it->next[PL_MAIN]) {
tracks[index++] = it;
}
undo_insert_items(undobuffer, plt, tracks, count);
free (tracks);
}
undo_insert_items(undobuffer, plt, tracks, count);
free (tracks);
pl_unlock ();
}
}
Expand Down

0 comments on commit 541593e

Please sign in to comment.