Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix possible failure in timeline preview

parent 7ab34d35
......@@ -50,8 +50,11 @@ PreviewManager::PreviewManager(TimelineController *controller, Mlt::Tractor *tra
int height = 1024 / dar;
height -= height % 4;
m_previewProfile->set_height(height);
m_previewProfile->set_sample_aspect(1, 1);
m_previewProfile->set_display_aspect(m_tractor->profile()->display_aspect_num(), m_tractor->profile()->display_aspect_den());
m_previewProfile->set_frame_rate(m_tractor->profile()->frame_rate_num(), m_tractor->profile()->frame_rate_den());
m_previewProfile->set_colorspace(m_tractor->profile()->colorspace());
m_previewProfile->set_progressive(m_tractor->profile()->progressive());
m_previewProfile->set_explicit(1);
}
......@@ -533,17 +536,7 @@ void PreviewManager::doPreviewRender(const QString &scene)
m_cacheDir.remove(fileName);
emit previewRender(0, QString(), 1000);
} else {
Mlt::Producer test(*m_tractor->profile(), "avformat", m_cacheDir.absoluteFilePath(fileName).toUtf8().constData());
if (test.is_valid()) {
emit previewRender(workingPreview, m_cacheDir.absoluteFilePath(fileName), progress);
} else {
// working chunk failed, re-add it to list and delete corrupt render
m_dirtyChunks << workingPreview;
qSort(m_dirtyChunks);
m_cacheDir.remove(fileName);
m_abortPreview = true;
emit previewRender(workingPreview, i18n("Preview rendering failed"), -1);
}
emit previewRender(workingPreview, m_cacheDir.absoluteFilePath(fileName), progress);
}
/*QStringList args;
args << scene;
......@@ -695,6 +688,7 @@ void PreviewManager::gotPreviewRender(int frame, const QString &file, int progre
m_previewTrack->insert_at(frame, &prod, 1);
} else {
qCDebug(KDENLIVE_LOG) << "* * * INVALID PROD: " << file;
corruptedChunk(frame, file);
}
} else {
qCDebug(KDENLIVE_LOG) << "* * * NON EMPTY PROD: " << frame;
......@@ -705,6 +699,17 @@ void PreviewManager::gotPreviewRender(int frame, const QString &file, int progre
pCore->currentDoc()->setModified(true);
}
void PreviewManager::corruptedChunk(int frame, const QString &fileName)
{
m_abortPreview = true;
emit abortPreview();
m_previewThread.waitForFinished();
m_cacheDir.remove(fileName);
m_dirtyChunks << frame;
qSort(m_dirtyChunks);
emit previewRender(frame, i18n("Preview rendering failed"), -1);
}
int PreviewManager::setOverlayTrack(Mlt::Playlist *overlay)
{
m_overlayTrack = overlay;
......
......@@ -115,6 +115,8 @@ private:
QFuture<void> m_previewThread;
/** @brief: After an undo/redo, if we have preview history, use it. */
void reloadChunks(const QVariantList chunks);
/** @brief: A chunk failed to render, abort. */
void corruptedChunk(int workingPreview, const QString &fileName);
private slots:
/** @brief: To avoid filling the hard drive, remove preview undo history after 5 steps. */
......
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