*Fix rendering crash

*Allow seeking in empty project
parent 464f3f00
......@@ -160,3 +160,27 @@ void BinPlaylist::saveProperty(const QString &name, const QString &value)
{
m_binPlaylist->set(name.toUtf8().constData(), value.toUtf8().constData());
}
QMap<QString, QString> BinPlaylist::getProxies(const QString &root)
{
QMap<QString, QString> proxies;
int size = m_binPlaylist->count();
for (int i = 0; i < size; i++) {
QScopedPointer<Mlt::Producer> prod(m_binPlaylist->get_clip(i));
if (!prod->is_valid() || prod->is_blank()) {
continue;
}
QString proxy = prod->parent().get("kdenlive:proxy");
if (proxy.length() > 2) {
if (QFileInfo(proxy).isRelative()) {
proxy.prepend(root);
}
QString sourceUrl(prod->parent().get("kdenlive:originalurl"));
if (QFileInfo(sourceUrl).isRelative()) {
sourceUrl.prepend(root);
}
proxies.insert(proxy, sourceUrl);
}
}
return proxies;
}
......@@ -69,6 +69,9 @@ public:
/** @brief Save a property to main bin */
void saveProperty(const QString &name, const QString &value);
/** @brief Retrieve a list of proxy/original urls */
QMap<QString, QString> getProxies(const QString &root);
// id of the mlt object
static QString binPlaylistId;
protected:
......
......@@ -837,3 +837,8 @@ void ProjectItemModel::saveProperty(const QString &name, const QString &value)
{
m_binPlaylist->saveProperty(name, value);
}
QMap<QString, QString> ProjectItemModel::getProxies(const QString &root)
{
return m_binPlaylist->getProxies(root);
}
......@@ -187,6 +187,9 @@ public:
/* @brief Retrieves the next id available for attribution to a clip */
int getFreeClipId();
/** @brief Retrieve a list of proxy/original urls */
QMap<QString, QString> getProxies(const QString &root);
protected:
/* @brief Register the existence of a new element
*/
......
......@@ -2149,7 +2149,7 @@ void MainWindow::slotZoneMoved(int start, int end)
void MainWindow::slotGuidesUpdated()
{
if (m_renderWidget) {
double projectDuration = GenTime(getMainTimeline()->controller()->duration(), pCore->getCurrentFps()).ms() / 1000;
double projectDuration = GenTime(getMainTimeline()->controller()->duration() - TimelineModel::seekDuration - 2, pCore->getCurrentFps()).ms() / 1000;
m_renderWidget->setGuides(pCore->currentDoc()->getGuideModel()->getAllMarkers(), projectDuration);
}
}
......@@ -3419,8 +3419,9 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
in = getMainTimeline()->controller()->zoneIn();
out = getMainTimeline()->controller()->zoneOut();
} else {
out = getMainTimeline()->controller()->duration() - 2;
out = getMainTimeline()->controller()->duration() - TimelineModel::seekDuration - 2;
}
QString playlistContent = pCore->projectManager()->projectSceneList(project->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile());
if (!chapterFile.isEmpty()) {
QDomDocument doc;
......@@ -3501,8 +3502,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
}
// replace proxy clips with originals
// TODO
QMap<QString, QString> proxies = pCore->binController()->getProxies(pCore->currentDoc()->documentRoot());
QMap<QString, QString> proxies = pCore->projectItemModel()->getProxies(pCore->currentDoc()->documentRoot());
QDomNodeList producers = doc.elementsByTagName(QStringLiteral("producer"));
QString producerResource;
......
......@@ -50,6 +50,7 @@
#include "macros.hpp"
int TimelineModel::next_id = 0;
int TimelineModel::seekDuration = 30000;
TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack> undo_stack)
: QAbstractItemModel_shared_from_this()
......@@ -73,7 +74,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
m_blackClip->set("length", INT_MAX);
m_blackClip->set("set.test_audio", 0);
m_blackClip->set("length", INT_MAX);
m_blackClip->set_in_and_out(0, 10);
m_blackClip->set_in_and_out(0, TimelineModel::seekDuration);
m_tractor->insert_track(*m_blackClip, 0);
#ifdef LOGGING
......@@ -1374,15 +1375,15 @@ bool TimelineModel::isGroup(int id) const
void TimelineModel::updateDuration()
{
int current = m_blackClip->get_playtime();
int duration = 10;
int current = m_blackClip->get_playtime() - TimelineModel::seekDuration;
int duration = 0;
for (const auto &tck : m_iteratorTable) {
auto track = (*tck.second);
duration = qMax(duration, track->trackDuration());
}
if (duration != current) {
// update black track length
m_blackClip->set_in_and_out(0, duration);
m_blackClip->set_in_and_out(0, duration + TimelineModel::seekDuration);
emit durationUpdated();
}
}
......
......@@ -416,6 +416,7 @@ public:
Returns the duration in frames
*/
int duration() const;
static int seekDuration; // Duration after project end where seeking is allowed
/* @brief Get all the elements of the same group as the given clip.
If there is a group hierarchy, only the topmost group is considered.
......
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