Fix playlist profile incorrectly detected, leading to crashes when seeking in timeline

(used the "consumer" producer instead of "xml"
Fix incorrect argument passed in reload timeline clip from bin
parent 19de4140
......@@ -135,8 +135,9 @@ std::shared_ptr<Mlt::Producer> LoadJob::loadPlaylist(QString &resource)
qDebug() << "////// ERROR, CANNOT LOAD SELECTED PLAYLIST: " << resource;
return nullptr;
}
std::unique_ptr<ProfileInfo> prof(new ProfileParam(xmlProfile.get()));
if (static_cast<ProfileInfo*>(pCore->getCurrentProfile().get()) == prof.get()) {
std::unique_ptr<ProfileParam> clipProfile(new ProfileParam(xmlProfile.get()));
std::unique_ptr<ProfileParam> projectProfile(new ProfileParam(pCore->getCurrentProfile().get()));
if (*clipProfile.get() == *projectProfile.get()) {
// We can use the "xml" producer since profile is the same (using it with different profiles corrupts the project.
// Beware that "consumer" currently crashes on audio mixes!
//resource.prepend(QStringLiteral("xml:"));
......
......@@ -418,7 +418,7 @@ void ClipModel::refreshProducerFromBin(int trackId, PlaylistState::ClipState sta
QWriteLocker locker(&m_lock);
int in = getIn();
int out = getOut();
if (!qFuzzyCompare(speed, m_speed) && !qFuzzyCompare(speed, 0.)) {
if (!qFuzzyCompare(speed, m_speed) && !qFuzzyIsNull(speed)) {
in = in * std::abs(m_speed / speed);
out = in + getPlaytime() - 1;
// prevent going out of the clip's range
......@@ -443,11 +443,15 @@ void ClipModel::refreshProducerFromBin(int trackId, PlaylistState::ClipState sta
m_endlessResize = !binClip->hasLimitedDuration();
}
void ClipModel::refreshProducerFromBin(int trackId, bool hasPitch)
void ClipModel::refreshProducerFromBin(int trackId)
{
if (trackId == -1) {
trackId = m_currentTrackId;
}
bool hasPitch = false;
if (!qFuzzyCompare(getSpeed(), 1.)) {
hasPitch = m_producer->parent().get_int("warp_pitch") == 1;
}
refreshProducerFromBin(trackId, m_currentState, 0, hasPitch);
}
......@@ -612,7 +616,7 @@ void ClipModel::setCurrentTrackId(int tid, bool finalMove)
}
if (finalMove && tid != -1 && m_lastTrackId != m_currentTrackId) {
refreshProducerFromBin(m_currentTrackId, m_currentState);
refreshProducerFromBin(m_currentTrackId);
m_lastTrackId = m_currentTrackId;
}
}
......@@ -626,7 +630,7 @@ Fun ClipModel::setClipState_lambda(PlaylistState::ClipState state)
// Enforce producer reload
m_lastTrackId = -1;
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_currentTrackId, m_currentState);
refreshProducerFromBin(m_currentTrackId);
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->dataChanged(ix, ix, {TimelineModel::StatusRole});
}
......
......@@ -180,7 +180,7 @@ protected:
* you are doing, better use useTimewarProducer to change the speed
*/
void refreshProducerFromBin(int trackId, PlaylistState::ClipState state, double speed, bool hasPitch);
void refreshProducerFromBin(int trackId, bool hasPitch);
void refreshProducerFromBin(int trackId);
/* @brief This functions replaces the current producer with a slowmotion one
It also resizes the producer so that set of frames contained in the clip is the same
......
......@@ -514,7 +514,7 @@ void TimelineItemModel::importTrackEffects(int tid, std::weak_ptr<Mlt::Service>
{
std::shared_ptr<TrackModel> track = getTrackById(tid);
std::shared_ptr<Mlt::Tractor> destination = track->getTrackService();
// Audio mixer effects are attached to the Tractor service, while track effects are attached to first playlist service
// Audio mixer effects are attached to the Tractor service, while track effects are attached to first playlist service
if (auto ptr = service.lock()) {
for (int i = 0; i < ptr->filter_count(); i++) {
std::unique_ptr<Mlt::Filter> filter(ptr->filter(i));
......
......@@ -945,11 +945,11 @@ bool TimelineModel::requestClipCreation(const QString &binClipId, int &id, Playl
Fun local_undo = deregisterClip_lambda(clipId);
ClipModel::construct(shared_from_this(), bid, clipId, state, speed, warp_pitch);
auto clip = m_allClips[clipId];
Fun local_redo = [clip, this, state]() {
Fun local_redo = [clip, this, state, speed, warp_pitch]() {
// We capture a shared_ptr to the clip, which means that as long as this undo object lives, the clip object is not deleted. To insert it back it is
// sufficient to register it.
registerClip(clip, true);
clip->refreshProducerFromBin(-1, state);
clip->refreshProducerFromBin(-1, state, speed, warp_pitch);
return true;
};
......@@ -3490,7 +3490,12 @@ void TimelineModel::requestClipReload(int clipId)
int oldPos = getClipPosition(clipId);
int oldOut = getClipIn(clipId) + getClipPlaytime(clipId);
int maxDuration = m_allClips[clipId]->getMaxDuration();
bool hasPitch = m_allClips[clipId]->getIntProperty(QStringLiteral("warp_pitch"));
bool hasPitch = false;
double speed = m_allClips[clipId]->getSpeed();
PlaylistState::ClipState state = m_allClips[clipId]->clipState();
if (!qFuzzyCompare(speed, 1.)) {
hasPitch = m_allClips[clipId]->getIntProperty(QStringLiteral("warp_pitch"));
}
// Check if clip out is longer than actual producer duration (if user forced duration)
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(getClipBinId(clipId));
bool refreshView = oldOut > (int)binClip->frameDuration();
......@@ -3498,7 +3503,7 @@ void TimelineModel::requestClipReload(int clipId)
getTrackById(old_trackId)->requestClipDeletion(clipId, refreshView, true, local_undo, local_redo, false, false);
}
if (old_trackId != -1) {
m_allClips[clipId]->refreshProducerFromBin(old_trackId, hasPitch);
m_allClips[clipId]->refreshProducerFromBin(old_trackId, state, 0, hasPitch);
getTrackById(old_trackId)->requestClipInsertion(clipId, oldPos, refreshView, true, local_undo, local_redo);
if (maxDuration != m_allClips[clipId]->getMaxDuration()) {
QModelIndex ix = makeClipIndexFromID(clipId);
......
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