Skip to content
Snippets Groups Projects
Commit 75d7835a authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Fix in ParameterTuningDelegate to update currently active editor on resetParameterTree action.

parent 4d46c1f4
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,11 @@ void IntensityDataPropertyWidget::setItem(SessionItem *item) ...@@ -79,6 +79,11 @@ void IntensityDataPropertyWidget::setItem(SessionItem *item)
} }
}, this); }, this);
m_currentItem->mapper()->setOnItemDestroy(
[this](SessionItem *) {
m_currentItem = 0;
}, this);
} }
......
...@@ -101,6 +101,13 @@ ParameterTuningDelegate::ParameterTuningDelegate(QObject *parent) ...@@ -101,6 +101,13 @@ ParameterTuningDelegate::ParameterTuningDelegate(QObject *parent)
} }
ParameterTuningDelegate::~ParameterTuningDelegate()
{
if(m_currentItem)
m_currentItem->mapper()->unsubscribe(this);
}
void ParameterTuningDelegate::paint(QPainter *painter, void ParameterTuningDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index) const const QModelIndex &index) const
...@@ -188,16 +195,15 @@ QWidget *ParameterTuningDelegate::createEditor(QWidget *parent, ...@@ -188,16 +195,15 @@ QWidget *ParameterTuningDelegate::createEditor(QWidget *parent,
m_contentLayout->addWidget(m_valueBox); m_contentLayout->addWidget(m_valueBox);
m_contentLayout->addWidget(m_slider); m_contentLayout->addWidget(m_slider);
// FIXME CHECK m_currentItem->mapper()->setOnValueChange(
// This mapping seems to be necessary only in the case when ModelTuningDelegate is active, [this](){
// when item changes its value from outside. It never happens it seems, so mapper m_valueBox->setValue(m_currentItem->value().toDouble());
// is not necessary. }, this);
// If one outcomment code below, the time life of ModelTuningDelegate will make application
// crash during the fitting. Check this again and remove commented. m_currentItem->mapper()->setOnItemDestroy(
// m_currentItem->mapper()->setOnValueChange( [this](SessionItem *) {
// [this](){ m_currentItem = 0;
// m_valueBox->setValue(m_currentItem->value().toDouble()); }, this);
// }, this);
m_contentWidget->setLayout(m_contentLayout); m_contentWidget->setLayout(m_contentLayout);
......
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
ParameterTuningDelegate(QObject *parent = 0); ParameterTuningDelegate(QObject *parent = 0);
~ParameterTuningDelegate();
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & /* index */) const QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & /* index */) const
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment