Commit 89e885c3 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix crash on undo clip deletion.

Fixes #640
parent 2dff5c2f
...@@ -200,21 +200,24 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel> model, const QS ...@@ -200,21 +200,24 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel> model, const QS
loadEffects(); loadEffects();
m_scrollTimer.start(); m_scrollTimer.start();
connect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh); connect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
connect(m_model.get(), &EffectStackModel::enabledStateChanged, [this]() { connect(m_model.get(), &EffectStackModel::enabledStateChanged, this, &EffectStackView::changeEnabledState);
int max = m_model->rowCount();
int currentActive = m_model->getActiveEffect();
if (currentActive < max && currentActive > -1) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
w->updateScene();
}
emit updateEnabledState();
});
connect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect); connect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect);
// m_builtStack->setModel(model, stackOwner()); // m_builtStack->setModel(model, stackOwner());
} }
void EffectStackView::changeEnabledState()
{
int max = m_model->rowCount();
int currentActive = m_model->getActiveEffect();
if (currentActive < max && currentActive > -1) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
w->updateScene();
}
emit updateEnabledState();
}
void EffectStackView::loadEffects() void EffectStackView::loadEffects()
{ {
//QMutexLocker lock(&m_mutex); //QMutexLocker lock(&m_mutex);
...@@ -372,6 +375,7 @@ void EffectStackView::unsetModel(bool reset) ...@@ -372,6 +375,7 @@ void EffectStackView::unsetModel(bool reset)
ObjectId item = m_model->getOwnerId(); ObjectId item = m_model->getOwnerId();
id = item.first == ObjectType::BinClip ? Kdenlive::ClipMonitor : Kdenlive::ProjectMonitor; id = item.first == ObjectType::BinClip ? Kdenlive::ClipMonitor : Kdenlive::ProjectMonitor;
disconnect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh); disconnect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
disconnect(m_model.get(), &EffectStackModel::enabledStateChanged, this, &EffectStackView::changeEnabledState);
disconnect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect); disconnect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect);
} }
if (reset) { if (reset) {
......
...@@ -108,6 +108,9 @@ private slots: ...@@ -108,6 +108,9 @@ private slots:
/** @brief Save current effect stack /** @brief Save current effect stack
*/ */
void slotSaveStack(); void slotSaveStack();
/** @brief Refresh the enabled state on widgets
*/
void changeEnabledState();
// void switchBuiltStack(bool show); // void switchBuiltStack(bool show);
......
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