Commit 534765c9 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix duplicate track compositing on project opening and broken opacity with background

Fixes #497
parent 30c3512d
......@@ -90,7 +90,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
if (!audioTrack) {
videoTracksIndexes << i;
}
ok = timeline->requestTrackInsertion(-1, tid, QString(), audioTrack, undo, redo);
ok = timeline->requestTrackInsertion(-1, tid, QString(), audioTrack, undo, redo, false);
if (track->get_int("kdenlive:locked_track") > 0) {
lockedTracksIndexes << tid;
}
......@@ -111,7 +111,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
if (!audioTrack) {
videoTracksIndexes << i;
}
ok = timeline->requestTrackInsertion(-1, tid, trackName, audioTrack, undo, redo);
ok = timeline->requestTrackInsertion(-1, tid, trackName, audioTrack, undo, redo, false);
int muteState = track->get_int("hide");
if (muteState > 0 && (!audioTrack || (audioTrack && muteState != 1))) {
timeline->setTrackProperty(tid, QStringLiteral("hide"), QString::number(muteState));
......
......@@ -111,7 +111,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
, m_snaps(new SnapModel())
, m_undoStack(std::move(undo_stack))
, m_profile(profile)
, m_blackClip(new Mlt::Producer(*profile, "color:0"))
, m_blackClip(new Mlt::Producer(*profile, "color:black"))
, m_lock(QReadWriteLock::Recursive)
, m_timelineEffectsEnabled(true)
, m_id(getNextId())
......@@ -2246,7 +2246,7 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
return result;
}
bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &trackName, bool audioTrack, Fun &undo, Fun &redo)
bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &trackName, bool audioTrack, Fun &undo, Fun &redo, bool addCompositing)
{
// TODO: make sure we disable overlayTrack before inserting a track
if (position == -1) {
......@@ -2279,17 +2279,23 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
buildTrackCompositing(true);
return true;
};
buildTrackCompositing(true);
if (addCompositing) {
buildTrackCompositing(true);
}
auto track = getTrackById(trackId);
Fun local_redo = [track, position, local_update, this]() {
Fun local_redo = [track, position, local_update, addCompositing, this]() {
// We capture a shared_ptr to the track, which means that as long as this undo object lives, the track object is not deleted. To insert it back it is
// sufficient to register it.
registerTrack(track, position, true);
local_update();
buildTrackCompositing(true);
if (addCompositing) {
buildTrackCompositing(true);
}
return true;
};
PUSH_LAMBDA(rebuild_compositing, local_undo);
if (addCompositing) {
PUSH_LAMBDA(rebuild_compositing, local_undo);
}
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
return true;
}
......
......@@ -505,7 +505,7 @@ public:
*/
bool requestTrackInsertion(int pos, int &id, const QString &trackName = QString(), bool audioTrack = false);
/* Same function, but accumulates undo and redo*/
bool requestTrackInsertion(int pos, int &id, const QString &trackName, bool audioTrack, Fun &undo, Fun &redo);
bool requestTrackInsertion(int pos, int &id, const QString &trackName, bool audioTrack, Fun &undo, Fun &redo, bool addCompositing = true);
/* @brief Delete track with given id
This also deletes all the clips contained in the track.
......
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