Commit e28d6127 authored by Artur Grunau's avatar Artur Grunau
Browse files

DataNamePropertyWidget: fix null pointer deref

If a DataNamePropertyWidget is created for a DataNameProperty whose
AccessInfo == READ, it doesn't instantiate a QLineEdit to display the
property's value (QComboBox is used instead).

Previously, the updateWidgetFromProperty method didn't check AccessInfo
to see what display widget was in use, and simply always dereferenced
the _lineEdit pointer. If AccessInfo == READ, it was null and the
application crashed.

Now updateWidgetFromProperty accesses only the combo box if
AccessInfo == READ, and uses the line edit otherwise.

Fixes #99
parent 97a051c5
......@@ -53,14 +53,9 @@ namespace campvis {
dc->s_dataAdded.connect(this, &DataNamePropertyWidget::onDataAdded);
int idx = _combobox->findText(QString::fromStdString(property->getValue()));
if (idx != -1)
connect(_combobox, SIGNAL(editTextChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
......@@ -80,13 +75,28 @@ namespace campvis {
void DataNamePropertyWidget::updateWidgetFromProperty() {
DataNameProperty* prop = static_cast<DataNameProperty*>(_property);
QString qs = QString::fromStdString(prop->getValue());
if (_lineEdit->text() != qs) {
if (prop->getAccessInfo() == DataNameProperty::READ) {
else if (_lineEdit->text() != qs) {
void DataNamePropertyWidget::setCurrentComboBoxText(const QString& text) {
int idx = _combobox->findText(text);
if (idx != -1)
void DataNamePropertyWidget::onTextChanged(const QString& text) {
DataNameProperty* prop = static_cast<DataNameProperty*>(_property);
......@@ -45,7 +45,7 @@ namespace campvis {
* Widget for a DataNameProperty
class DataNamePropertyWidget : public AbstractPropertyWidget {
......@@ -72,6 +72,16 @@ namespace campvis {
void onTextChanged(const QString& text);
* Set the combo box's current text to the provided value.
* If \c text can already be found in the combo box, the corresponding item is made active. Otherwise, \c text
* is set as the contents of the combo box's text edit.
* \param text text to be set in the combo box
void setCurrentComboBoxText(const QString& text);
QLineEdit* _lineEdit;
QComboBox* _combobox;
DataContainer* _dc;
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