Fix freeze on memory usage loading invalid clips

parent 1156c6d7
......@@ -351,7 +351,12 @@ bool AudioThumbJob::startJob()
}
m_lengthInFrames = m_prod->get_length(); // Multiply this if we want more than 1 sample per frame
int thumbResolution = 3000;
if (m_lengthInFrames == INT_MAX) {
// This is a broken file or live feed, don't attempt to generate audio thumbnails
m_done = true;
m_successful = false;
return false;
}
// Increase audio thumb resolution for longer clips to get a better resolution
if (m_lengthInFrames > 10000) {
// More than 10 minutes at 25fps
......@@ -363,7 +368,6 @@ bool AudioThumbJob::startJob()
}
}
m_thumbSize = QSize(thumbResolution, 1000 / pCore->getCurrentDar());
m_frequency = m_binClip->audioInfo()->samplingRate();
m_frequency = m_frequency <= 0 ? 48000 : m_frequency;
......
......@@ -411,6 +411,19 @@ bool LoadJob::startJob()
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
if (m_producer->get_length() == INT_MAX && m_producer->get("eof") == QLatin1String("loop")) {
// This is a live source or broken clip
m_done = true;
m_successful = false;
if (m_producer) {
m_producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60);
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", m_resource)),
Q_ARG(int, (int)KMessageWidget::Warning));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
processProducerProperties(m_producer, m_xml);
QString clipName = Xml::getXmlProperty(m_xml, QStringLiteral("kdenlive:clipname"));
if (clipName.isEmpty()) {
......
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