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 crash on opening a project with filters

parent 09ba4a45
......@@ -38,7 +38,9 @@ public:
@param is a ptr to the model this item belongs to. This is required to send update signals
*/
static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack);
/* This construct an effect with an already existing filter
Only used when loading an existing clip
*/
static std::shared_ptr<EffectItemModel> construct(Mlt::Properties *effect, std::shared_ptr<AbstractTreeModel> stack);
/* @brief This function plants the effect into the given service in last position
......
......@@ -36,6 +36,7 @@ EffectStackModel::EffectStackModel(std::weak_ptr<Mlt::Service> service, ObjectId
, m_effectStackEnabled(true)
, m_ownerId(ownerId)
, m_undoStack(undo_stack)
, m_loadingExisting(false)
{
}
......@@ -49,6 +50,7 @@ std::shared_ptr<EffectStackModel> EffectStackModel::construct(std::weak_ptr<Mlt:
void EffectStackModel::loadEffects()
{
auto ptr = m_service.lock();
m_loadingExisting = true;
if (ptr) {
for (int i = 0; i < ptr->filter_count(); i++) {
if (ptr->filter(i)->get("kdenlive_id") == nullptr) {
......@@ -65,6 +67,7 @@ void EffectStackModel::loadEffects()
qDebug() << "// CANNOT LOCK CLIP SEEVCE";
}
this->modelChanged();
m_loadingExisting = false;
}
void EffectStackModel::resetService(std::weak_ptr<Mlt::Service> service)
......@@ -271,10 +274,12 @@ void EffectStackModel::registerItem(const std::shared_ptr<TreeItem> &item)
QModelIndex ix;
if (!item->isRoot()) {
auto effectItem = std::static_pointer_cast<AbstractEffectItem>(item);
effectItem->plant(m_service);
if (!m_loadingExisting) {
effectItem->plant(m_service);
}
effectItem->setEffectStackEnabled(m_effectStackEnabled);
ix = getIndexFromItem(effectItem);
if (!effectItem->isAudio()) {
if (!effectItem->isAudio() && !m_loadingExisting) {
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
}
......
......@@ -119,6 +119,10 @@ private:
mutable QReadWriteLock m_lock;
QList<int> fadeIns;
QList<int> fadeOuts;
/** @brief: When loading a project, we load filters/effects that are already planted
* in the producer, so we shouldn't plant them again. Setting this value to
* true will prevent planting in the producer */
bool m_loadingExisting;
signals:
void modelChanged();
......
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