diff --git a/app/timeline/timelineundopointer.cpp b/app/timeline/timelineundopointer.cpp index 864ce468b..c54941704 100644 --- a/app/timeline/timelineundopointer.cpp +++ b/app/timeline/timelineundopointer.cpp @@ -203,6 +203,8 @@ void TrackSlideCommand::redo() in_adjacent_remove_command_->redo_now(); } + + we_removed_in_adjacent_ = true; } else { // Simply resize adjacent in_adjacent_->set_length_and_media_out(in_adjacent_->length() + movement_); @@ -225,6 +227,8 @@ void TrackSlideCommand::redo() out_adjacent_remove_command_->redo_now(); } + + we_removed_out_adjacent_ = true; } else { // Simply resize adjacent out_adjacent_->set_length_and_media_in(out_adjacent_->length() - movement_); @@ -246,9 +250,13 @@ void TrackSlideCommand::undo() // We created this, so we can remove it now track_->RippleRemoveBlock(in_adjacent_); in_adjacent_->setParent(&memory_manager_); - } else if (in_adjacent_remove_command_) { - // We removed this, so we can restore it now - in_adjacent_remove_command_->undo_now(); + } else if (we_removed_in_adjacent_) { + if (in_adjacent_remove_command_) { + // We removed this, so we can restore it now + in_adjacent_remove_command_->undo_now(); + } + + track_->InsertBlockBefore(in_adjacent_, blocks_.first()); } else { // Simply resize adjacent in_adjacent_->set_length_and_media_out(in_adjacent_->length() - movement_); @@ -259,8 +267,12 @@ void TrackSlideCommand::undo() // We created this, so we can remove it now track_->RippleRemoveBlock(out_adjacent_); out_adjacent_->setParent(&memory_manager_); - } else if (out_adjacent_remove_command_) { - out_adjacent_remove_command_->undo_now(); + } else if (we_removed_out_adjacent_) { + if (out_adjacent_remove_command_) { + out_adjacent_remove_command_->undo_now(); + } + + track_->InsertBlockAfter(out_adjacent_, blocks_.last()); } else { out_adjacent_->set_length_and_media_in(out_adjacent_->length() + movement_); } diff --git a/app/timeline/timelineundopointer.h b/app/timeline/timelineundopointer.h index 05adf590e..ad5acf197 100644 --- a/app/timeline/timelineundopointer.h +++ b/app/timeline/timelineundopointer.h @@ -116,8 +116,10 @@ public: track_(track), blocks_(moving_blocks), movement_(movement), + we_removed_in_adjacent_(false), in_adjacent_(in_adjacent), in_adjacent_remove_command_(nullptr), + we_removed_out_adjacent_(false), out_adjacent_(out_adjacent), out_adjacent_remove_command_(nullptr) { @@ -148,9 +150,11 @@ private: rational movement_; bool we_created_in_adjacent_; + bool we_removed_in_adjacent_; Block* in_adjacent_; UndoCommand* in_adjacent_remove_command_; bool we_created_out_adjacent_; + bool we_removed_out_adjacent_; Block* out_adjacent_; UndoCommand* out_adjacent_remove_command_;