Fix timeline keeping aspect ratio of initial profile after switch

parent 5777f4db
Pipeline #15755 passed with stage
in 13 minutes and 51 seconds
......@@ -563,7 +563,7 @@ void TimelineItemModel::buildTrackCompositing(bool rebuild)
field->lock();
// Make sure all previous track compositing is removed
if (rebuild) {
QScopedPointer<Mlt::Service> service(new Mlt::Service(field->get_service()));
QScopedPointer<Mlt::Service> service(m_tractor->field());
while (service != nullptr && service->is_valid()) {
if (service->type() == transition_type) {
Mlt::Transition t((mlt_transition)service->get_service());
......@@ -588,16 +588,16 @@ void TimelineItemModel::buildTrackCompositing(bool rebuild)
std::unique_ptr<Mlt::Transition> transition = TransitionsRepository::get()->getTransition(composite);
transition->set("internal_added", 237);
transition->set("always_active", 1);
field->plant_transition(*transition, 0, trackPos);
transition->set_tracks(0, trackPos);
field->plant_transition(*transition, 0, trackPos);
} else if ((*it)->isAudioTrack()) {
// audio mix
std::unique_ptr<Mlt::Transition> transition = TransitionsRepository::get()->getTransition(QStringLiteral("mix"));
transition->set("internal_added", 237);
transition->set("always_active", 1);
transition->set("sum", 1);
field->plant_transition(*transition, 0, trackPos);
transition->set_tracks(0, trackPos);
field->plant_transition(*transition, 0, trackPos);
if (hasMixer) {
pCore->mixer()->registerTrack((*it)->getId(), (*it)->getTrackService(), getTrackTagById((*it)->getId()));
}
......
......@@ -3514,6 +3514,19 @@ void TimelineModel::updateProfile(Mlt::Profile *profile)
{
m_profile = profile;
m_tractor->set_profile(*m_profile);
for (int i = 0; i < m_tractor->count(); i++) {
std::shared_ptr<Mlt::Producer> tk(m_tractor->track(i));
tk->set_profile(*m_profile);
if (tk->type() == multitrack_type) {
Mlt::Tractor sub(*tk.get());
for (int j = 0; j < sub.count(); j++) {
std::shared_ptr<Mlt::Producer> subtk(sub.track(j));
subtk->set_profile(*m_profile);
}
}
}
// Rebuild compositions since profile has changed
buildTrackCompositing(true);
}
int TimelineModel::getBlankSizeNearClip(int clipId, bool after) const
......
......@@ -1681,9 +1681,9 @@ void TimelineController::changeItemSpeed(int clipId, double speed)
void TimelineController::switchCompositing(int mode)
{
// m_model->m_tractor->lock();
pCore->currentDoc()->setDocumentProperty(QStringLiteral("compositing"), QString::number(mode));
pCore->currentDoc()->setDocumentProperty(QStringLiteral("compositing"), QString::number(mode));
QScopedPointer<Mlt::Service> service(m_model->m_tractor->field());
Mlt::Field *field = m_model->m_tractor->field();
QScopedPointer<Mlt::Field>field(m_model->m_tractor->field());
field->lock();
while ((service != nullptr) && service->is_valid()) {
if (service->type() == transition_type) {
......@@ -1707,8 +1707,7 @@ void TimelineController::switchCompositing(int mode)
Mlt::Transition t(*m_model->m_tractor->profile(),
mode == 1 ? "composite" : TransitionsRepository::get()->getCompositingTransition().toUtf8().constData());
t.set("always_active", 1);
t.set("a_track", 0);
t.set("b_track", track + 1);
t.set_tracks(0, track + 1);
if (mode == 1) {
t.set("valign", "middle");
t.set("halign", "centre");
......@@ -1722,7 +1721,6 @@ void TimelineController::switchCompositing(int mode)
}
}
field->unlock();
delete field;
pCore->requestMonitorRefresh();
}
......
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