Cleanup timeline clip replacement

parent e8f6078a
......@@ -3486,11 +3486,11 @@ void Bin::cleanup()
m_itemModel->requestCleanup();
}
void Bin::prepareTimelineReplacement(const requestClipInfo &info)
void Bin::prepareTimelineReplacement(const requestClipInfo &info, const std::shared_ptr<Mlt::Producer> &producer)
{
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(info.clipId);
Q_ASSERT(clip != nullptr);
slotProducerReady(info, nullptr);
slotProducerReady(info, producer);
clip->replaceInTimeline();
}
......
......@@ -428,7 +428,7 @@ public slots:
void doUpdateThumbsProgress(long ms);
void droppedUrls(const QList<QUrl> &urls, const QStringList &folderInfo = QStringList());
/** @brief A clip producer was changed and needs to be replaced in timeline. */
void prepareTimelineReplacement(const requestClipInfo &info);
void prepareTimelineReplacement(const requestClipInfo &info, const std::shared_ptr<Mlt::Producer> &producer);
/** @brief Returns the effectstack of a given clip. */
std::shared_ptr<EffectStackModel> getClipEffectStack(int itemId);
protected:
......
......@@ -223,28 +223,6 @@ int BinController::clipCount() const
return m_clipList.size();
}
void BinController::replaceProducer(const requestClipInfo &info, const std::shared_ptr<Mlt::Producer> &producer)
{
if (!m_clipList.contains(info.clipId)) {
qCDebug(KDENLIVE_LOG) << " / // error controller not found, crashing";
return;
}
std::shared_ptr<ClipController> ctrl = m_clipList.value(info.clipId);
if (ctrl->isValid()) {
pasteEffects(info.clipId, producer);
}
ctrl->updateProducer(producer);
replaceBinPlaylistClip(info.clipId, producer);
producer->set("id", info.clipId.toUtf8().constData());
// Remove video only producer
QString videoId = info.clipId + QStringLiteral("_video");
if (m_extraClipList.contains(videoId)) {
m_extraClipList.remove(videoId);
}
removeBinPlaylistClip("#" + info.clipId);
emit prepareTimelineReplacement(info);
}
void BinController::addClipToBin(const QString &id, const std::shared_ptr<ClipController> &controller, bool fromPlaylist)
{
/** Test: we can use filters on clips in the bin this way
......@@ -328,7 +306,7 @@ Mlt::Producer *BinController::getBinVideoProducer(const QString &id)
std::shared_ptr<Mlt::Producer> original = getBinProducer(originalId);
Mlt::Producer *videoOnly = cloneProducer(*original.get());
videoOnly->set("audio_index", -1);
videoOnly->set("id", videoId.toUtf8().constData());
videoOnly->set("kdenlive:id", videoId.toUtf8().constData());
m_extraClipList.insert(videoId, videoOnly);
return videoOnly;
}
......
......@@ -165,7 +165,6 @@ public:
public slots:
/** @brief Stored a Bin Folder id / name to MLT's bin playlist. Using an empry folderName deletes the property */
void slotStoreFolder(const QString &folderId, const QString &parentId, const QString &oldParentId, const QString &folderName);
void replaceProducer(const requestClipInfo &info, const std::shared_ptr<Mlt::Producer> &producer);
private:
/** @brief The MLT playlist holding our Producers */
......@@ -198,7 +197,7 @@ signals:
void setDocumentNotes(const QString &);
void updateTimelineProducer(const QString &);
/** @brief We want to replace a clip with another, but before we need to change clip producer id so that there is no interference*/
void prepareTimelineReplacement(const requestClipInfo &);
void prepareTimelineReplacement(const requestClipInfo &, const std::shared_ptr<Mlt::Producer> &);
/** @brief Indicate which clip we are loading */
void loadingBin(int);
void slotProducerReady(const requestClipInfo &info, std::shared_ptr<Mlt::Producer> producer);
......
......@@ -586,8 +586,9 @@ void ClipPropertiesController::slotColorModified(const QColor &newcolor)
{
QMap<QString, QString> properties;
properties.insert(QStringLiteral("resource"), newcolor.name(QColor::HexArgb));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
QMap<QString, QString> oldProperties;
oldProperties.insert(QStringLiteral("resource"), m_properties.get("resource"));
emit updateClipProperties(m_id, oldProperties, properties);
}
void ClipPropertiesController::slotDurationChanged(int duration)
......
......@@ -183,7 +183,6 @@ void ProducerQueue::processFileProperties()
m_processingClipId.append(info.clipId);
m_infoMutex.unlock();
// TODO: read all xml meta.kdenlive properties into a QMap or an MLT::Properties and pass them to the newly created producer
QString path;
bool proxyProducer;
QString proxy = ProjectClip::getXmlProperty(info.xml, QStringLiteral("kdenlive:proxy"));
......@@ -461,11 +460,11 @@ void ProducerQueue::processFileProperties()
int fullWidth = info.imageHeight * m_binController->profile()->dar() + 0.5;
int frameNumber = ProjectClip::getXmlProperty(info.xml, QStringLiteral("kdenlive:thumbnailFrame"), QStringLiteral("-1")).toInt();
producer->set("kdenlive:id", info.clipId.toUtf8().constData());
if ((!info.replaceProducer && !EffectsList::property(info.xml, QStringLiteral("kdenlive:file_hash")).isEmpty()) || proxyProducer) {
if ((info.replaceProducer && !EffectsList::property(info.xml, QStringLiteral("kdenlive:file_hash")).isEmpty()) || proxyProducer) {
// Clip already has all properties
// We want to replace an existing producer. We MUST NOT set the producer's id property until
// the old one has been removed.
// We want to replace an existing producer.
if (proxyProducer) {
// Recreate clip thumb
Mlt::Frame *frame = nullptr;
......@@ -513,13 +512,10 @@ void ProducerQueue::processFileProperties()
producer->set(name.toUtf8().constData(), e.firstChild().nodeValue().toUtf8().constData());
}
}
QMetaObject::invokeMethod(m_binController.get(), "replaceProducer", Qt::QueuedConnection, Q_ARG(const requestClipInfo &, info),
QMetaObject::invokeMethod(m_binController.get(), "prepareTimelineReplacement", Qt::QueuedConnection, Q_ARG(const requestClipInfo &, info),
Q_ARG(const std::shared_ptr<Mlt::Producer> &, producer));
continue;
}
// We are not replacing an existing producer, so set the id
producer->set("id", info.clipId.toUtf8().constData());
producer->set("kdenlive:id", info.clipId.toUtf8().constData());
stringMap filePropertyMap;
stringMap metadataPropertyMap;
char property[200];
......
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