Fix crash opening old project file

Fixes #196
parent ff513186
Pipeline #3769 passed with stage
in 20 minutes and 54 seconds
......@@ -649,9 +649,11 @@ bool ProjectItemModel::requestAddBinClip(QString &id, const std::shared_ptr<Mlt:
bool res = addItem(new_clip, parentId, undo, redo);
if (res) {
new_clip->importEffects(producer);
int blocking = pCore->jobManager()->getBlockingJobId(id, AbstractClipJob::LOADJOB);
pCore->jobManager()->startJob<ThumbJob>({id}, blocking, QString(), 150, -1, true);
pCore->jobManager()->startJob<AudioThumbJob>({id}, blocking, QString());
if (new_clip->sourceExists()) {
int blocking = pCore->jobManager()->getBlockingJobId(id, AbstractClipJob::LOADJOB);
pCore->jobManager()->startJob<ThumbJob>({id}, blocking, QString(), 150, -1, true);
pCore->jobManager()->startJob<AudioThumbJob>({id}, blocking, QString());
}
}
return res;
}
......
......@@ -2226,7 +2226,7 @@ void DocumentValidator::checkOrphanedProducers()
int max = producers.count();
QStringList allProducers;
for (int i = 0; i < max; ++i) {
QDomElement prod = producers.at(i).toElement();
QDomElement prod = producers.item(i).toElement();
if (prod.isNull()) {
continue;
}
......@@ -2235,8 +2235,8 @@ void DocumentValidator::checkOrphanedProducers()
QDomDocumentFragment frag = m_doc.createDocumentFragment();
QDomDocumentFragment trackProds = m_doc.createDocumentFragment();
for (int i = 0; i < max; ++i) {
QDomElement prod = producers.at(i).toElement();
for (int i = 0; i < producers.count(); ++i) {
QDomElement prod = producers.item(i).toElement();
if (prod.isNull()) {
continue;
}
......@@ -2258,9 +2258,9 @@ void DocumentValidator::checkOrphanedProducers()
distinctiveTag = QStringLiteral("xmldata");
}
QString orphanValue = Xml::getXmlProperty(prod, distinctiveTag);
for (int j = 0; j < max; j++) {
for (int j = 0; j < producers.count(); j++) {
// Search for a similar producer
QDomElement binProd = producers.at(j).toElement();
QDomElement binProd = producers.item(j).toElement();
binId = binProd.attribute(QStringLiteral("id")).section(QLatin1Char('_'), 0, 0);
if (service != QLatin1String("timewarp") && (binId.startsWith(QLatin1String("slowmotion")) || !binProducers.contains(binId))) {
continue;
......@@ -2274,7 +2274,9 @@ void DocumentValidator::checkOrphanedProducers()
if (binValue == orphanValue) {
// Found probable source producer, replace
frag.appendChild(prod);
i--;
if (i > 0) {
i--;
}
QDomNodeList entries = m_doc.elementsByTagName(QStringLiteral("entry"));
for (int k = 0; k < entries.count(); k++) {
QDomElement entry = entries.at(k).toElement();
......
......@@ -488,6 +488,18 @@ const QString ClipController::clipUrl() const
return m_path;
}
bool ClipController::sourceExists() const
{
if (m_clipType == ClipType::Color || m_clipType == ClipType::Text) {
return true;
}
if (m_clipType == ClipType::SlideShow) {
//TODO
return true;
}
return QFile::exists(m_path);
}
QString ClipController::clipName() const
{
QString name = getProducerProperty(QStringLiteral("kdenlive:clipname"));
......
......@@ -65,6 +65,9 @@ public:
/** @brief Returns true if the master producer is valid */
bool isValid();
/** @brief Returns true if the source file exists */
bool sourceExists() const;
/** @brief Stores the file's creation time */
QDateTime date;
......
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