Browse Source

fix clip editor region being unset when moving tracks

translate
Alexandros Theodotou 2 months ago
parent
commit
8ad61d70c0
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 11
      src/actions/tracklist_selections.c
  2. 4
      src/gui/backend/clip_editor.c
  3. 41
      tests/actions/tracklist_selections.c

11
src/actions/tracklist_selections.c

@ -1249,6 +1249,10 @@ do_or_undo_move_or_copy ( @@ -1249,6 +1249,10 @@ do_or_undo_move_or_copy (
bool pin = self->type == TRACKLIST_SELECTIONS_ACTION_PIN;
bool unpin = self->type == TRACKLIST_SELECTIONS_ACTION_UNPIN;
/* if moving, this will be set back */
ZRegion * prev_clip_editor_region =
clip_editor_get_region (CLIP_EDITOR);
if (_do)
{
Track * foldable_tr = NULL;
@ -1638,6 +1642,13 @@ do_or_undo_move_or_copy ( @@ -1638,6 +1642,13 @@ do_or_undo_move_or_copy (
self->tls_before->num_tracks;
}
if (move)
{
clip_editor_set_region (
CLIP_EDITOR, prev_clip_editor_region,
F_NO_PUBLISH_EVENTS);
}
/* restore connections */
save_or_load_port_connections (self, _do);

4
src/gui/backend/clip_editor.c

@ -58,6 +58,10 @@ clip_editor_set_region ( @@ -58,6 +58,10 @@ clip_editor_set_region (
g_return_if_fail (IS_REGION (region));
}
g_message (
"clip editor: setting region to %p (%s)", region,
region ? region->name : NULL);
/* if first time showing a region, show the
* event viewer as necessary */
if (fire_events && !self->has_region && region)

41
tests/actions/tracklist_selections.c

@ -2901,6 +2901,44 @@ test_copy_after_uninstalling_plugin (void) @@ -2901,6 +2901,44 @@ test_copy_after_uninstalling_plugin (void)
#endif
}
static void
test_move_track_w_clip_editor_region (void)
{
test_helper_zrythm_init ();
char * midi_file = g_build_filename (
TESTS_SRCDIR, "1_empty_track_1_track_with_data.mid", NULL);
SupportedFile * file =
supported_file_new_from_path (midi_file);
g_free (midi_file);
int num_tracks_before = TRACKLIST->num_tracks;
bool success = track_create_with_action (
TRACK_TYPE_MIDI, NULL, file, PLAYHEAD, num_tracks_before,
1, NULL);
g_assert_true (success);
Track * first_track = TRACKLIST->tracks[num_tracks_before];
track_select (
first_track, F_SELECT, F_EXCLUSIVE, F_NO_PUBLISH_EVENTS);
ZRegion * r = first_track->lanes[0]->regions[0];
arranger_object_select (
(ArrangerObject *) r, F_SELECT, F_NO_APPEND,
F_NO_PUBLISH_EVENTS);
clip_editor_set_region (CLIP_EDITOR, r, F_NO_PUBLISH_EVENTS);
ZRegion * clip_editor_region =
clip_editor_get_region (CLIP_EDITOR);
g_assert_nonnull (clip_editor_region);
tracklist_selections_action_perform_move (
TRACKLIST_SELECTIONS, PORT_CONNECTIONS_MGR,
TRACKLIST->num_tracks, NULL);
clip_editor_region = clip_editor_get_region (CLIP_EDITOR);
g_assert_nonnull (clip_editor_region);
undo_manager_undo (UNDO_MANAGER, NULL);
clip_editor_region = clip_editor_get_region (CLIP_EDITOR);
g_assert_nonnull (clip_editor_region);
test_helper_zrythm_cleanup ();
}
int
main (int argc, char * argv[])
{
@ -2908,6 +2946,9 @@ main (int argc, char * argv[]) @@ -2908,6 +2946,9 @@ main (int argc, char * argv[])
#define TEST_PREFIX "/actions/tracklist_selections/"
g_test_add_func (
TEST_PREFIX "test move track w clip editor region",
(GTestFunc) test_move_track_w_clip_editor_region);
g_test_add_func (
TEST_PREFIX "test track deletion with plugin",
(GTestFunc) test_track_deletion_with_plugin);

Loading…
Cancel
Save