Fix crash opening old project, fix disabled clips not saved.

Fixes #174
parent c900e5b3
Pipeline #3017 passed with stage
in 13 minutes and 21 seconds
......@@ -620,8 +620,6 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int trackId, int
Mlt::Properties cloneProps(warpProducer->get_properties());
cloneProps.pass_list(original, ClipController::getPassPropertiesList(false));
warpProducer->set("length", double(original_length) / std::abs(speed));
}
qDebug() << "warp LENGTH" << warpProducer->get_length();
......@@ -660,13 +658,11 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
std::shared_ptr<Mlt::Producer> prod(getTimelineProducer(-1, clipId, state, speed)->cut(in, out));
return {prod, false};
}
if (state == PlaylistState::Disabled && !m_disabledProducer) {
qDebug() << "Warning: weird, we found a disabled clip whose master is already loaded but we don't have any yet";
createDisabledMasterProducer();
return {std::shared_ptr<Mlt::Producer>(m_disabledProducer->cut(in, out)), false};
}
if (state == PlaylistState::Disabled && QString::fromUtf8(m_disabledProducer->get("id")) != QString::fromUtf8(master->parent().get("id"))) {
qDebug() << "Warning: weird, we found a disabled clip whose master is already loaded but doesn't match ours";
if (state == PlaylistState::Disabled) {
if (!m_disabledProducer) {
qDebug() << "Warning: weird, we found a disabled clip whose master is already loaded but we don't have any yet";
createDisabledMasterProducer();
}
return {std::shared_ptr<Mlt::Producer>(m_disabledProducer->cut(in, out)), false};
}
// We have a good id, this clip can be used
......@@ -689,11 +685,11 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
m_effectStack->loadService(m_videoProducers[clipId]);
return {master, true};
}
if (state == PlaylistState::Disabled && !m_disabledProducer) {
// good, we found a master disabled producer, and we didn't have any
m_disabledProducer.reset(master->parent().cut());
m_effectStack->loadService(m_disabledProducer);
return {master, true};
if (state == PlaylistState::Disabled) {
if (!m_disabledProducer) {
createDisabledMasterProducer();
}
return {std::make_shared<Mlt::Producer>(m_disabledProducer->cut(master->get_in(), master->get_out())), true};
}
qDebug() << "Warning: weird, we found a clip whose master is not loaded but we already have a master";
Q_ASSERT(false);
......
......@@ -2246,6 +2246,7 @@ void DocumentValidator::checkOrphanedProducers()
}
if (!binProducers.contains(id)) {
QString binId = Xml::getXmlProperty(prod, QStringLiteral("kdenlive:binid"));
Xml::setXmlProperty(prod, QStringLiteral("kdenlive:id"), binId);
if (!binId.isEmpty() && binProducers.contains(binId)) {
continue;
}
......
......@@ -533,7 +533,7 @@ void ClipModel::setCurrentTrackId(int tid, bool finalMove)
return;
}
bool registerSnap = m_currentTrackId == -1 && tid > -1;
if (m_currentTrackId > -1 && tid == -1) {
// Removing clip
m_clipMarkerModel->deregisterSnapModel();
......@@ -555,23 +555,9 @@ Fun ClipModel::setClipState_lambda(PlaylistState::ClipState state)
QWriteLocker locker(&m_lock);
return [this, state]() {
if (auto ptr = m_parent.lock()) {
switch (state) {
case PlaylistState::Disabled:
m_producer->set("set.test_audio", 1);
m_producer->set("set.test_image", 1);
break;
case PlaylistState::VideoOnly:
m_producer->set("set.test_image", 0);
break;
case PlaylistState::AudioOnly:
m_producer->set("set.test_audio", 0);
break;
default:
// error
break;
}
m_currentState = state;
if (m_currentTrackId != -1 && ptr->isClip(m_id)) { // if this is false, the clip is being created. Don't update model in that case
refreshProducerFromBin(m_currentState);
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->dataChanged(ix, ix, {TimelineModel::StatusRole});
}
......
......@@ -557,27 +557,24 @@ bool TimelineFunctions::changeClipState(const std::shared_ptr<TimelineItemModel>
int track = timeline->getClipTrackId(clipId);
int start = -1;
int end = -1;
bool invalidate = false;
if (track > -1) {
if (!timeline->getTrackById_const(track)->isAudioTrack()) {
start = timeline->getItemPosition(clipId);
end = start + timeline->getItemPlaytime(clipId);
invalidate = true;
}
start = timeline->getItemPosition(clipId);
end = start + timeline->getItemPlaytime(clipId);
}
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
bool result = timeline->m_allClips[clipId]->setClipState(status, local_undo, local_redo);
Fun local_update = [start, end, timeline]() {
if (start > -1) {
timeline->invalidateZone(start, end);
timeline->checkRefresh(start, end);
}
return true;
};
if (start > -1) {
local_update();
PUSH_LAMBDA(local_update, local_redo);
PUSH_LAMBDA(local_update, local_undo);
// For the state change to work, we need to unplant/replant the clip
bool result = true;
if (track > -1) {
result = timeline->getTrackById(track)->requestClipDeletion(clipId, true, invalidate, local_undo, local_redo);
}
result = timeline->m_allClips[clipId]->setClipState(status, local_undo, local_redo);
if (result && track > -1) {
result = timeline->getTrackById(track)->requestClipInsertion(clipId, start, true, true, local_undo, local_redo);
}
UPDATE_UNDO_REDO_NOLOCK(local_redo, local_undo, undo, redo);
return result;
......
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