1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00
Clear bound combo box lists on board disconnect to ensure that we get
new options added on the next connected signal. This ensures that
different board types always get the correct options when connected.
This commit is contained in:
dwillis 2014-07-05 01:44:55 +01:00
parent 5c085823cf
commit 4e78d3cafa

View File

@ -230,7 +230,21 @@ UAVObjectManager *ConfigTaskWidget::getObjectManager()
void ConfigTaskWidget::onAutopilotDisconnect() void ConfigTaskWidget::onAutopilotDisconnect()
{ {
m_isConnected = false; m_isConnected = false;
// Reset board ID and clear bound combo box lists to force repopulation
// when we get another connected signal. This means that we get the
// correct values in combo boxes bound to fields with limits applied.
m_currentBoardId = -1;
foreach(WidgetBinding * binding, m_widgetBindingsPerObject) {
QComboBox *cb;
if (binding->widget() && (cb = qobject_cast<QComboBox *>(binding->widget()))) {
cb->clear();
}
}
enableControls(false); enableControls(false);
invalidateObjects(); invalidateObjects();
} }
@ -275,7 +289,8 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
bool dirtyBack = isDirty(); bool dirtyBack = isDirty();
emit refreshWidgetsValuesRequested(); emit refreshWidgetsValuesRequested();
foreach(WidgetBinding * binding, obj == NULL ? m_widgetBindingsPerObject.values() : m_widgetBindingsPerObject.values(obj)) { QList<WidgetBinding *> bindings = obj == NULL ? m_widgetBindingsPerObject.values() : m_widgetBindingsPerObject.values(obj);
foreach(WidgetBinding * binding, bindings) {
if (binding->isEnabled() && binding->field() != NULL && binding->widget() != NULL) { if (binding->isEnabled() && binding->field() != NULL && binding->widget() != NULL) {
setWidgetFromField(binding->widget(), binding->field(), binding); setWidgetFromField(binding->widget(), binding->field(), binding);
} }
@ -983,7 +998,7 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field,
// this check, we would add all the board dependent options whether they were // this check, we would add all the board dependent options whether they were
// valid or not. Ultimately this method will be called again when the connected // valid or not. Ultimately this method will be called again when the connected
// signal is handled. // signal is handled.
if(m_currentBoardId > -1) { if (m_currentBoardId > -1) {
foreach(QString str, option) { foreach(QString str, option) {
if (field->isWithinLimits(str, index, m_currentBoardId)) { if (field->isWithinLimits(str, index, m_currentBoardId)) {
cb->addItem(str); cb->addItem(str);