Commit 76725da8 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Workaround for a Qt bug in the instrument viewer

When using a lineEdit and hitting Enter, the editionFinished() signal is
sent twice. This is due to a known Qt bug, and so a workaround is to
ignore the second signal.
This bug is fixed in Qt 5.14.
First bug report : https://bugreports.qt.io/browse/QTBUG-40
parent 1a2ab406
......@@ -27,7 +27,6 @@ DoubleEditor::DoubleEditor(QtProperty *property, QWidget *parent)
setValidator(new QDoubleValidator(mgr->minimum(property),
mgr->maximum(property), 20, this));
connect(this, SIGNAL(editingFinished()), this, SLOT(updateProperty()));
// double val = mgr->value(property);
setValue(mgr->value(property));
}
......@@ -36,11 +35,16 @@ DoubleEditor::~DoubleEditor() {}
void DoubleEditor::setValue(const double &d) { setText(formatValue(d)); }
void DoubleEditor::updateProperty() {
if (!this->isModified())
return;
// Ignore second signal if two were triggered by pressing the Enter key
// see https://bugreports.qt.io/browse/QTBUG-40
this->setModified(false);
auto mgr =
dynamic_cast<QtDoublePropertyManager *>(m_property->propertyManager());
if (mgr) {
if (mgr)
mgr->setValue(m_property, text().toDouble());
}
}
/**
......
Supports Markdown
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