On project loading, ensure clip state fits with its parent track

parent bedee196
......@@ -192,7 +192,7 @@ bool constructTrackFromMelt(const std::shared_ptr<TimelineItemModel> &timeline,
namespace {
// This function tries to recover the state of the producer (audio or video or both)
PlaylistState::ClipState inferState(std::shared_ptr<Mlt::Producer> prod)
PlaylistState::ClipState inferState(std::shared_ptr<Mlt::Producer> prod, bool audioTrack)
{
auto getProperty = [prod](const QString &name) {
if (prod->parent().is_valid()) {
......@@ -210,10 +210,10 @@ PlaylistState::ClipState inferState(std::shared_ptr<Mlt::Producer> prod)
std::pair<bool, bool> VidAud{true, true};
VidAud.first = getIntProperty("set.test_image") == 0;
VidAud.second = getIntProperty("set.test_audio") == 0;
if (service.contains(QStringLiteral("avformat")) && getIntProperty(QStringLiteral("video_index")) == -1) {
if (audioTrack || (service.contains(QStringLiteral("avformat")) && getIntProperty(QStringLiteral("video_index")) == -1)) {
VidAud.first = false;
}
if (service.contains(QStringLiteral("avformat")) && getIntProperty(QStringLiteral("audio_index")) == -1) {
if (!audioTrack || (service.contains(QStringLiteral("avformat")) && getIntProperty(QStringLiteral("audio_index")) == -1)) {
VidAud.second = false;
}
return stateFromBool(VidAud);
......@@ -223,6 +223,7 @@ PlaylistState::ClipState inferState(std::shared_ptr<Mlt::Producer> prod)
bool constructTrackFromMelt(const std::shared_ptr<TimelineItemModel> &timeline, int tid, Mlt::Playlist &track,
const std::unordered_map<QString, QString> &binIdCorresp, Fun &undo, Fun &redo)
{
bool audioTrack = track.get_int("kdenlive:audio_track") == 1;
for (int i = 0; i < track.count(); i++) {
if (track.is_blank(i)) {
continue;
......@@ -250,7 +251,7 @@ bool constructTrackFromMelt(const std::shared_ptr<TimelineItemModel> &timeline,
}
bool ok = false;
if (pCore->bin()->getBinClip(binId)) {
PlaylistState::ClipState st = inferState(clip);
PlaylistState::ClipState st = inferState(clip, audioTrack);
int cid = ClipModel::construct(timeline, binId, clip, st);
ok = timeline->requestClipMove(cid, tid, position, true, false, undo, redo);
} else {
......
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