Don't auto split a clip if dropped on an audio track. Fix crash on undo insert...

Don't auto split a clip if dropped on an audio track. Fix crash on undo insert zone with locked track
parent fefe4795
......@@ -192,6 +192,10 @@ bool TimelineFunctions::insertZone(std::shared_ptr<TimelineItemModel> timeline,
auto it = timeline->m_allTracks.cbegin();
while (it != timeline->m_allTracks.cend()) {
int target_track = (*it)->getId();
if (timeline->getTrackById_const(target_track)->isLocked()) {
++it;
continue;
}
int startClipId = timeline->getClipByPosition(target_track, insertFrame);
if (startClipId > -1) {
// There is a clip, cut it
......
......@@ -297,6 +297,9 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
return false;
}
Q_ASSERT(isClip(clipId));
if (getTrackById_const(trackId)->isLocked()) {
return false;
}
std::function<bool(void)> local_undo = []() { return true; };
std::function<bool(void)> local_redo = []() { return true; };
bool ok = true;
......@@ -312,9 +315,6 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
return false;
}
}
if (getTrackById_const(trackId)->isLocked()) {
return false;
}
ok = getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, local_undo, local_redo);
if (!ok) {
// qDebug()<<"-------------\n\nINSERTION FAILED, REVERTING\n\n-------------------";
......@@ -608,9 +608,10 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
type = master->clipType();
}
if (type == ClipType::AV) {
res = requestClipCreation(binClipId, id, PlaylistState::VideoOnly, local_undo, local_redo);
bool audioDrop = getTrackById_const(trackId)->isAudioTrack();
res = requestClipCreation(binClipId, id, audioDrop ? PlaylistState::AudioOnly : PlaylistState::VideoOnly, local_undo, local_redo);
res = res && requestClipMove(id, trackId, position, refreshView, logUndo, local_undo, local_redo);
if (res && logUndo) {
if (res && logUndo && !audioDrop) {
QList<int> possibleTracks = m_audioTarget >= 0 ? QList<int>() << m_audioTarget : getLowerTracksId(trackId, TrackType::AudioTrack);
if (possibleTracks.isEmpty()) {
// No available audio track for splitting, abort
......
......@@ -138,7 +138,7 @@ Fun TrackModel::requestClipInsertion_lambda(int clipId, int position, bool updat
ptr->_endInsertRows();
int state = m_track->get_int("hide");
bool audioOnly = clip->isAudioOnly();
if (!audioOnly && (state == 0 || state == 2) && m_track->get_int("kdenlive:audio_track") != 1) {
if (!audioOnly && (state == 0 || state == 2) && !isAudioTrack()) {
// only refresh monitor if not an audio track and not hidden
ptr->checkRefresh(new_in, new_out);
}
......@@ -275,7 +275,7 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView)
// deleted last clip in playlist
ptr->updateDuration();
}
if (!audioOnly && (state == 0 || state == 2) && m_track->get_int("kdenlive:audio_track") != 1) {
if (!audioOnly && (state == 0 || state == 2) && !isAudioTrack()) {
// only refresh monitor if not an audio track and not hidden
ptr->checkRefresh(old_in, old_out);
}
......@@ -393,7 +393,7 @@ Fun TrackModel::requestClipResize_lambda(int clipId, int in, int out, bool right
int size = out - in + 1;
int state = m_track->get_int("hide");
bool checkRefresh = false;
if ((state == 0 || state == 2) && m_track->get_int("kdenlive:audio_track") != 1) {
if ((state == 0 || state == 2) && !isAudioTrack()) {
checkRefresh = true;
}
......@@ -988,3 +988,8 @@ bool TrackModel::isLocked() const
READ_LOCK();
return m_track->get_int("kdenlive:locked_track");
}
bool TrackModel::isAudioTrack() const
{
return m_track->get_int("kdenlive:audio_track");
}
......@@ -84,6 +84,9 @@ public:
/* Returns true if track is in locked state
*/
bool isLocked() const;
/* Returns true if track is an audio track
*/
bool isAudioTrack() const;
// TODO make protected
QVariant getProperty(const QString &name) const;
......
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