Commit 84f26e14 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix possible crash in effectstack.

Related to crash 1 in #495
parent 3339a0f9
......@@ -136,10 +136,13 @@ int AbstractTreeModel::rowCount(const QModelIndex &parent) const
QModelIndex AbstractTreeModel::getIndexFromItem(const std::shared_ptr<TreeItem> &item) const
{
if (item == rootItem) {
return {};
return QModelIndex();
}
if (auto ptr = item->parentItem().lock()) {
auto parentIndex = getIndexFromItem(ptr);
return index(item->row(), 0, parentIndex);
}
auto parentIndex = getIndexFromItem(item->parentItem().lock());
return index(item->row(), 0, parentIndex);
return QModelIndex();
}
QModelIndex AbstractTreeModel::getIndexFromId(int id) const
......
......@@ -311,10 +311,12 @@ void EffectStackView::slotAdjustDelegate(const std::shared_ptr<EffectItemModel>
return;
}
QModelIndex ix = m_model->getIndexFromItem(effectModel);
auto *del = static_cast<WidgetDelegate *>(m_effectsTree->itemDelegate(ix));
if (del) {
del->setHeight(ix, newHeight);
QMetaObject::invokeMethod(this, "updateTreeHeight", Qt::QueuedConnection);
if (ix.isValid()) {
auto *del = static_cast<WidgetDelegate *>(m_effectsTree->itemDelegate(ix));
if (del) {
del->setHeight(ix, newHeight);
QMetaObject::invokeMethod(this, "updateTreeHeight", Qt::QueuedConnection);
}
}
}
......
......@@ -48,6 +48,7 @@
#include <QQmlEngine>
#include <QQuickItem>
#include <QUuid>
#include <QFontDatabase>
#include <QSortFilterProxyModel>
const int TimelineWidget::comboScale[] = {1, 2, 4, 8, 15, 30, 50, 75, 100, 150, 200, 300, 500, 800, 1000, 1500, 2000, 3000, 6000, 15000, 30000};
......@@ -83,6 +84,7 @@ TimelineWidget::TimelineWidget(QWidget *parent)
m_thumbnailer = new ThumbnailProvider;
engine()->addImageProvider(QStringLiteral("thumbnail"), m_thumbnailer);
setVisible(false);
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setFocusPolicy(Qt::StrongFocus);
}
......
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