Fix error causing clip duplication in memory on project opening

parent a495168a
......@@ -664,8 +664,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int trackId, int
return std::shared_ptr<Mlt::Producer>(warpProducer->cut());
}
std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTimelineProducer(int clipId, std::shared_ptr<Mlt::Producer> master,
PlaylistState::ClipState state)
std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTimelineProducer(int clipId, std::shared_ptr<Mlt::Producer> master, PlaylistState::ClipState state, int tid)
{
int in = master->get_in();
int out = master->get_out();
......@@ -703,16 +702,16 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
return {master, true};
}
if (state == PlaylistState::AudioOnly) {
m_audioProducers[clipId] = std::make_shared<Mlt::Producer>(&master->parent());
m_effectStack->loadService(m_audioProducers[clipId]);
m_audioProducers[tid] = std::make_shared<Mlt::Producer>(&master->parent());
m_effectStack->loadService(m_audioProducers[tid]);
return {master, true};
}
if (state == PlaylistState::VideoOnly) {
// good, we found a master video producer, and we didn't have any
if (m_clipType != ClipType::Color && m_clipType != ClipType::Image && m_clipType != ClipType::Text) {
// Color, image and text clips always use master producer in timeline
m_videoProducers[clipId] = std::make_shared<Mlt::Producer>(&master->parent());
m_effectStack->loadService(m_videoProducers[clipId]);
m_videoProducers[tid] = std::make_shared<Mlt::Producer>(&master->parent());
m_effectStack->loadService(m_videoProducers[tid]);
}
return {master, true};
}
......
......@@ -209,8 +209,7 @@ public:
- if true, then the returned cut still possibly has effect on it. You need to rebuild the effectStack based on this
- if false, then the returned cut don't have effects anymore (it's a fresh one), so you need to reload effects from the old producer
*/
std::pair<std::shared_ptr<Mlt::Producer>, bool> giveMasterAndGetTimelineProducer(int clipId, std::shared_ptr<Mlt::Producer> master,
PlaylistState::ClipState state);
std::pair<std::shared_ptr<Mlt::Producer>, bool> giveMasterAndGetTimelineProducer(int clipId, std::shared_ptr<Mlt::Producer> master, PlaylistState::ClipState state, int tid);
std::shared_ptr<Mlt::Producer> cloneProducer(bool removeEffects = false);
static std::shared_ptr<Mlt::Producer> cloneProducer(const std::shared_ptr<Mlt::Producer> &producer);
......
......@@ -328,7 +328,7 @@ bool constructTrackFromMelt(const std::shared_ptr<TimelineItemModel> &timeline,
int cid = -1;
if (pCore->bin()->getBinClip(binId)) {
PlaylistState::ClipState st = inferState(clip, audioTrack);
cid = ClipModel::construct(timeline, binId, clip, st);
cid = ClipModel::construct(timeline, binId, clip, st, tid);
ok = timeline->requestClipMove(cid, tid, position, true, true, false, true, undo, redo);
} else {
qDebug() << "// Cannot find bin clip: " << binId << " - " << clip->get("id");
......
......@@ -97,7 +97,7 @@ void ClipModel::allSnaps(std::vector<int> &snaps)
}
int ClipModel::construct(const std::shared_ptr<TimelineModel> &parent, const QString &binClipId, const std::shared_ptr<Mlt::Producer> &producer,
PlaylistState::ClipState state)
PlaylistState::ClipState state, int tid)
{
// we hand the producer to the bin clip, and in return we get a cut to a good master producer
......@@ -119,7 +119,7 @@ int ClipModel::construct(const std::shared_ptr<TimelineModel> &parent, const QSt
speed = producer->parent().get_double("warp_speed");
warp_pitch = producer->parent().get_int("warp_pitch");
}
auto result = binClip->giveMasterAndGetTimelineProducer(id, producer, state);
auto result = binClip->giveMasterAndGetTimelineProducer(id, producer, state, tid);
std::shared_ptr<ClipModel> clip(new ClipModel(parent, result.first, binClipId, id, state, speed));
if (warp_pitch) {
result.first->parent().set("warp_pitch", 1);
......
......@@ -65,7 +65,7 @@ public:
Note that there is no guarantee that this producer is actually going to be used. It might be discarded.
*/
static int construct(const std::shared_ptr<TimelineModel> &parent, const QString &binClipId, const std::shared_ptr<Mlt::Producer> &producer,
PlaylistState::ClipState state);
PlaylistState::ClipState state, int tid);
/** @brief returns a property of the clip, or from it's parent if it's a cut
*/
......
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