Fix effects inserted in wrong row after deletion undo

parent 00b0e45a
......@@ -315,13 +315,13 @@ Fun AbstractTreeModel::removeItem_lambda(int id)
};
}
Fun AbstractTreeModel::moveItem_lambda(int id, int destRow)
Fun AbstractTreeModel::moveItem_lambda(int id, int destRow, bool force)
{
Fun lambda = []() { return true; };
std::vector<std::shared_ptr<TreeItem>> oldStack;
auto item = getItemById(id);
if (item->row() == destRow) {
if (!force && item->row() == destRow) {
// nothing to do
return lambda;
}
......
......@@ -76,7 +76,7 @@ public:
Fun removeItem_lambda(int id);
/* @brief Helper function to generate a lambda that changes the row of an item */
Fun moveItem_lambda(int id, int destRow);
Fun moveItem_lambda(int id, int destRow, bool force = false);
/* @brief Returns the number of clips in bin */
int clipsCount() const;
......
......@@ -95,7 +95,12 @@ void EffectStackModel::removeEffect(std::shared_ptr<EffectItemModel> effect)
srv->set("kdenlive:activeeffect", --current);
}
}
int currentRow = effect->row();
Fun undo = addItem_lambda(effect, parentId);
if (currentRow != rowCount() - 1) {
Fun move = moveItem_lambda(effect->getId(), currentRow, true);
PUSH_LAMBDA(move, undo);
}
Fun redo = removeItem_lambda(effect->getId());
bool res = redo();
if (res) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment