mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-369 : in case there is an objectID mismatch, still try to update the object if we found the name, but place it in "warning" mode. If during update some fields do not exist, then place in "Error" mode and prevent automated saving (will still try to update as many fields as possible)
This commit is contained in:
parent
56b63613ba
commit
2a5ff0b36a
@ -150,9 +150,14 @@ void UAVObjectUtilManager::objectPersistenceTransactionCompleted(UAVObject* obj,
|
||||
saveState = AWAITING_COMPLETED;
|
||||
disconnect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectPersistenceTransactionCompleted(UAVObject*,bool)));
|
||||
failureTimer.start(1000); // Create a timeout
|
||||
} else if (!success) {
|
||||
// Can be caused by timeout errors on sending. Send again.
|
||||
} else {
|
||||
// Can be caused by timeout errors on sending. Forget it and send next.
|
||||
qDebug() << "objectPersistenceTranscationCompleted (error)";
|
||||
UAVObject *obj = getObjectManager()->getObject(ObjectPersistence::NAME);
|
||||
obj->disconnect(this);
|
||||
queue.dequeue(); // We can now remove the object, it failed anyway.
|
||||
saveState = IDLE;
|
||||
emit saveCompleted(obj->getField("ObjectID")->getValue().toInt(), false);
|
||||
saveNextObject();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ ImportSummaryDialog::~ImportSummaryDialog()
|
||||
Adds a new line about a UAVObject along with its status
|
||||
(whether it got saved OK or not)
|
||||
*/
|
||||
void ImportSummaryDialog::addLine(QString uavObjectName, bool status)
|
||||
void ImportSummaryDialog::addLine(QString uavObjectName, QString text, bool status)
|
||||
{
|
||||
ui->importSummaryList->setRowCount(ui->importSummaryList->rowCount()+1);
|
||||
int row = ui->importSummaryList->rowCount()-1;
|
||||
@ -64,11 +64,10 @@ void ImportSummaryDialog::addLine(QString uavObjectName, bool status)
|
||||
QTableWidgetItem *objName = new QTableWidgetItem(uavObjectName);
|
||||
ui->importSummaryList->setItem(row, 1, objName);
|
||||
QCheckBox *box = dynamic_cast<QCheckBox*>(ui->importSummaryList->cellWidget(row,0));
|
||||
ui->importSummaryList->setItem(row,2,new QTableWidgetItem(text));
|
||||
if (status) {
|
||||
ui->importSummaryList->setItem(row,2,new QTableWidgetItem("OK"));
|
||||
box->setChecked(true);
|
||||
} else {
|
||||
ui->importSummaryList->setItem(row,2,new QTableWidgetItem("Mismatch"));
|
||||
box->setChecked(false);
|
||||
box->setEnabled(false);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class ImportSummaryDialog : public QDialog
|
||||
public:
|
||||
ImportSummaryDialog(QWidget *parent=0);
|
||||
~ImportSummaryDialog();
|
||||
void addLine(QString objectName, bool status);
|
||||
void addLine(QString objectName, QString text, bool status);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
|
@ -157,35 +157,44 @@ void UAVSettingsImportExportPlugin::importUAVSettings()
|
||||
if (obj == NULL) {
|
||||
// This object is unknown!
|
||||
qDebug() << "Object Unknown:" << uavObjectName << uavObjectID;
|
||||
swui.addLine(uavObjectName, false);
|
||||
swui.addLine(uavObjectName, "Error", false);
|
||||
|
||||
} else if(uavObjectID != obj->getObjID()) {
|
||||
qDebug() << "Mismatch for Object " << uavObjectName << uavObjectID << " - " << obj->getObjID();
|
||||
swui.addLine(uavObjectName, false);
|
||||
} else {
|
||||
// - Update each field
|
||||
// - Issue and "updated" command
|
||||
bool error=false;
|
||||
QDomNode field = node.firstChild();
|
||||
while(!field.isNull()) {
|
||||
QDomElement f = field.toElement();
|
||||
if (f.tagName() == "field") {
|
||||
UAVObjectField *uavfield = obj->getField(f.attribute("name"));
|
||||
QStringList list = f.attribute("values").split(",");
|
||||
if (list.length() == 1) {
|
||||
uavfield->setValue(f.attribute("values"));
|
||||
} else {
|
||||
// This is an enum:
|
||||
int i=0;
|
||||
if (uavfield) {
|
||||
QStringList list = f.attribute("values").split(",");
|
||||
foreach (QString element, list) {
|
||||
uavfield->setValue(element,i++);
|
||||
if (list.length() == 1) {
|
||||
uavfield->setValue(f.attribute("values"));
|
||||
} else {
|
||||
// This is an enum:
|
||||
int i=0;
|
||||
QStringList list = f.attribute("values").split(",");
|
||||
foreach (QString element, list) {
|
||||
uavfield->setValue(element,i++);
|
||||
}
|
||||
}
|
||||
error = false;
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
field = field.nextSibling();
|
||||
}
|
||||
obj->updated();
|
||||
swui.addLine(uavObjectName, true);
|
||||
if (error) {
|
||||
swui.addLine(uavObjectName, "Error", false);
|
||||
} else if (uavObjectID != obj->getObjID()) {
|
||||
qDebug() << "Mismatch for Object " << uavObjectName << uavObjectID << " - " << obj->getObjID();
|
||||
swui.addLine(uavObjectName, "Warning", true);
|
||||
} else
|
||||
swui.addLine(uavObjectName, "OK", true);
|
||||
}
|
||||
}
|
||||
node = node.nextSibling();
|
||||
|
Loading…
Reference in New Issue
Block a user