Fix crash undoing cut when left part was selected

parent 4d325cbd
......@@ -148,6 +148,7 @@ Fun GroupsModel::destructGroupItem_lambda(int id)
removeFromGroup(id);
auto ptr = m_parent.lock();
if (!ptr) Q_ASSERT(false);
ptr->clearGroupSelectionOnDelete(id);
for (int child : m_downLink[id]) {
m_upLink[child] = -1;
QModelIndex ix;
......
......@@ -266,7 +266,7 @@ bool TimelineFunctions::requestClipCut(const std::shared_ptr<TimelineItemModel>
int newClip = timeline->getClipByPosition(trackToSelect, position);
if (newClip > -1) {
timeline->requestSetSelection({newClip});
}
}
}
return count > 0;
}
......
......@@ -4878,6 +4878,15 @@ void TimelineModel::requestClearSelection(bool onDeletion, Fun &undo, Fun &redo)
}
}
void TimelineModel::clearGroupSelectionOnDelete(int gid)
{
READ_LOCK();
if (gid == m_currentSelection) {
requestClearSelection(true);
}
}
std::unordered_set<int> TimelineModel::getCurrentSelection() const
{
READ_LOCK();
......
......@@ -689,6 +689,11 @@ public:
@param onDeletion is true when the selection is cleared as a result of a deletion
*/
Q_INVOKABLE bool requestClearSelection(bool onDeletion = false);
/** @brief On group deletion, ensure the group was not selected, clear selection otherwise
@param gid The group id
*/
void clearGroupSelectionOnDelete(int gid);
// same function with undo/redo accumulation
void requestClearSelection(bool onDeletion, Fun &undo, Fun &redo);
......
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