Clean up and fix possible corruption on missing bin clip id

Related to #533
parent 6c5f1960
......@@ -620,7 +620,7 @@ bool ProjectItemModel::requestAddFolder(QString &id, const QString &name, const
{
QWriteLocker locker(&m_lock);
if (!id.isEmpty() && !isIdFree(id)) {
id = QString();
id.clear();
}
if (id.isEmpty()) {
id = QString::number(getFreeFolderId());
......@@ -641,7 +641,7 @@ bool ProjectItemModel::requestAddBinClip(QString &id, const QDomElement &descrip
id = QString::number(getFreeClipId());
}
}
Q_ASSERT(!id.isEmpty() && isIdFree(id));
Q_ASSERT(isIdFree(id));
qDebug() << "/////////// found id" << id;
std::shared_ptr<ProjectClip> new_clip =
ProjectClip::construct(id, description, m_blankThumb, std::static_pointer_cast<ProjectItemModel>(shared_from_this()));
......@@ -683,7 +683,7 @@ bool ProjectItemModel::requestAddBinClip(QString &id, const std::shared_ptr<Mlt:
id = QString::number(getFreeClipId());
}
}
Q_ASSERT(!id.isEmpty() && isIdFree(id));
Q_ASSERT(isIdFree(id));
std::shared_ptr<ProjectClip> new_clip = ProjectClip::construct(id, m_blankThumb, std::static_pointer_cast<ProjectItemModel>(shared_from_this()), producer);
bool res = addItem(new_clip, parentId, undo, redo);
if (res) {
......@@ -703,7 +703,7 @@ bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const
if (id.isEmpty()) {
id = QString::number(getFreeClipId());
}
Q_ASSERT(!id.isEmpty() && isIdFree(id));
Q_ASSERT(isIdFree(id));
QString subId = parentId;
if (subId.startsWith(QLatin1Char('A')) || subId.startsWith(QLatin1Char('V'))) {
subId.remove(0, 1);
......@@ -909,6 +909,9 @@ bool ProjectItemModel::loadFolders(Mlt::Properties &folders)
bool ProjectItemModel::isIdFree(const QString &id) const
{
READ_LOCK();
if (id.isEmpty()) {
return false;
}
for (const auto &clip : m_allItems) {
auto c = std::static_pointer_cast<AbstractProjectItem>(clip.second.lock());
if (c->clipId() == id) {
......
......@@ -1477,14 +1477,7 @@ void RenderWidget::generateRenderFiles(QDomDocument doc, const QString &playlist
for (int i = 0; i < prods.count(); ++i) {
auto prod = prods.at(i).toElement();
if (prod.attribute(QStringLiteral("id")) == QStringLiteral("black_track")) {
auto props = prod.elementsByTagName(QStringLiteral("property"));
for (int j = 0; j < props.count(); ++j) {
auto prop = props.at(j).toElement();
if (prop.attribute(QStringLiteral("name")) == QStringLiteral("resource")) {
prop.firstChild().setNodeValue(QStringLiteral("transparent"));
break;
}
}
Xml::setXmlProperty(prod, QStringLiteral("resource"), QStringLiteral("transparent"));
break;
}
}
......
......@@ -134,6 +134,7 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
qCDebug(KDENLIVE_LOG) << "// WARNING, USING INVALID PRODUCER";
} else {
checkAudioVideo();
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
QString proxy = m_properties->get("kdenlive:proxy");
m_service = m_properties->get("mlt_service");
QString path = m_properties->get("resource");
......@@ -151,7 +152,6 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
m_path = path.isEmpty() ? QString() : QFileInfo(path).absoluteFilePath();
getInfoForProducer();
emitProducerChanged(m_controllerBinId, producer);
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
}
connectEffectStack();
}
......@@ -352,6 +352,7 @@ void ClipController::updateProducer(const std::shared_ptr<Mlt::Producer> &produc
*m_masterProducer = producer.get();
m_properties = new Mlt::Properties(m_masterProducer->get_properties());
m_producerLock.unlock();
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
checkAudioVideo();
// Pass properties from previous producer
m_properties->pass_list(passProperties, passList);
......
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