Commit 422e526a authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Prevent possible crash closing project with a track effect

parent f19c2faa
Pipeline #93705 passed with stage
in 8 minutes and 47 seconds
......@@ -259,7 +259,7 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo, bool l
// Now, we are in the state in which the timeline should be when we try to revert current action. So we can build the reverse action from here
if (m_currentTrackId != -1) {
if (auto ptr = m_parent.lock()) {
if (trackDuration > 0) {
if (trackDuration > 0 && !closing) {
// Operation changed parent track duration, update effect stack
int newDuration = ptr->getTrackById_const(m_currentTrackId)->trackDuration();
if (logUndo || trackDuration != newDuration) {
......
......@@ -1620,20 +1620,26 @@ bool TrackModel::requestRemoveMix(std::pair<int, int> clipIds, Fun &undo, Fun &r
return false;
}
bool result = false;
bool closing = false;
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
if (auto ptr = m_parent.lock()) {
// Resize first part clip
result = ptr->getClipPtr(clipIds.first)->requestResize(secondInPos - firstInPos, true, local_undo, local_redo, true, true);
// Resize main clip
result = result && ptr->getClipPtr(clipIds.second)->requestResize(endPos - secondInPos, false, local_undo, local_redo, true, true);
closing = ptr->m_closing;
if (closing) {
result = true;
} else {
result = ptr->getClipPtr(clipIds.first)->requestResize(secondInPos - firstInPos, true, local_undo, local_redo, true, true);
// Resize main clip
result = result && ptr->getClipPtr(clipIds.second)->requestResize(endPos - secondInPos, false, local_undo, local_redo, true, true);
}
}
if (result) {
PUSH_LAMBDA(local_redo, redo);
QString assetId = m_sameCompositions[clipIds.second]->getAssetId();
QVector<QPair<QString, QVariant>> params = m_sameCompositions[clipIds.second]->getAllParameters();
Fun replay = [this, clipIds, secondInPos, clipHasEndMix, src_track]() {
if (src_track == 1 && !clipHasEndMix) {
Fun replay = [this, clipIds, secondInPos, clipHasEndMix, src_track, closing]() {
if (src_track == 1 && !clipHasEndMix && !closing) {
// Revert clip to playlist 0 since it has no mix
switchPlaylist(clipIds.second, secondInPos, 1, 0);
}
......
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