mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-245 config: made binding more NULL safe
This commit is contained in:
parent
5c1e61979d
commit
27c9fa2372
@ -366,7 +366,7 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
|
||||
|
||||
QList<WidgetBinding *> bindings = obj == NULL ? m_widgetBindingsPerObject.values() : m_widgetBindingsPerObject.values(obj);
|
||||
foreach(WidgetBinding * binding, bindings) {
|
||||
if (binding->field() != NULL && binding->widget() != NULL) {
|
||||
if (binding->field() && binding->widget()) {
|
||||
if (binding->isEnabled()) {
|
||||
setWidgetFromField(binding->widget(), binding->field(), binding);
|
||||
} else {
|
||||
@ -384,7 +384,7 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
|
||||
void ConfigTaskWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
foreach(WidgetBinding * binding, m_widgetBindingsPerObject) {
|
||||
if (binding->object() != NULL && binding->field() != NULL) {
|
||||
if (binding->object() && binding->field()) {
|
||||
binding->updateObjectFieldFromValue();
|
||||
}
|
||||
}
|
||||
@ -419,9 +419,10 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav
|
||||
m_saveButton->addSaveButton(save);
|
||||
}
|
||||
foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) {
|
||||
m_saveButton->addObject((UAVDataObject *)binding->object());
|
||||
if (binding->object()) {
|
||||
m_saveButton->addObject((UAVDataObject *)binding->object());
|
||||
}
|
||||
}
|
||||
updateEnableControls();
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::enableControls(bool enable)
|
||||
@ -824,7 +825,7 @@ void ConfigTaskWidget::reloadButtonClicked()
|
||||
|
||||
QList<objectComparator> temp;
|
||||
foreach(WidgetBinding * binding, bindings) {
|
||||
if (binding->isEnabled() && binding->object() != NULL) {
|
||||
if (binding->isEnabled() && binding->object()) {
|
||||
objectComparator value;
|
||||
value.objid = binding->object()->getObjID();
|
||||
value.objinstid = binding->object()->getInstID();
|
||||
|
@ -42,11 +42,13 @@ void SmartSaveButton::addApplyButton(QPushButton *apply)
|
||||
buttonList.insert(apply, apply_button);
|
||||
connect(apply, SIGNAL(clicked()), this, SLOT(processClick()));
|
||||
}
|
||||
|
||||
void SmartSaveButton::addSaveButton(QPushButton *save)
|
||||
{
|
||||
buttonList.insert(save, save_button);
|
||||
connect(save, SIGNAL(clicked()), this, SLOT(processClick()));
|
||||
}
|
||||
|
||||
void SmartSaveButton::processClick()
|
||||
{
|
||||
emit beginOp();
|
||||
@ -76,6 +78,9 @@ void SmartSaveButton::processOperation(QPushButton *button, bool save)
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
||||
foreach(UAVDataObject * obj, objects) {
|
||||
if (!obj) {
|
||||
continue;
|
||||
}
|
||||
UAVObject::Metadata mdata = obj->getMetadata();
|
||||
|
||||
// Should we really save this object to the board?
|
||||
@ -165,24 +170,29 @@ void SmartSaveButton::setObjects(QList<UAVDataObject *> list)
|
||||
void SmartSaveButton::addObject(UAVDataObject *obj)
|
||||
{
|
||||
Q_ASSERT(obj);
|
||||
if (!objects.contains(obj)) {
|
||||
if (obj && !objects.contains(obj)) {
|
||||
objects.append(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void SmartSaveButton::removeObject(UAVDataObject *obj)
|
||||
{
|
||||
if (objects.contains(obj)) {
|
||||
Q_ASSERT(obj);
|
||||
if (obj && objects.contains(obj)) {
|
||||
objects.removeAll(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void SmartSaveButton::removeAllObjects()
|
||||
{
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
void SmartSaveButton::clearObjects()
|
||||
{
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
void SmartSaveButton::transaction_finished(UAVObject *obj, bool result)
|
||||
{
|
||||
if (current_object == obj) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user