1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-10 18:24:11 +01:00

Make the object saving throw an error message on save failures.

This commit is contained in:
James Cotton 2011-09-02 13:26:28 -05:00
parent 1d04715476
commit 5a9da23615

View File

@ -34,6 +34,8 @@
#include <QDebug> #include <QDebug>
#include <QEventLoop> #include <QEventLoop>
#include <QTimer> #include <QTimer>
#include <QErrorMessage>
#include <objectpersistence.h>
// ****************************** // ******************************
// constructor/destructor // constructor/destructor
@ -168,18 +170,30 @@ void UAVObjectUtilManager::objectPersistenceTransactionCompleted(UAVObject* obj,
*/ */
void UAVObjectUtilManager::objectPersistenceOperationFailed() void UAVObjectUtilManager::objectPersistenceOperationFailed()
{ {
qDebug() << "objectPersistenceOperationFailed";
if(saveState == AWAITING_COMPLETED) { if(saveState == AWAITING_COMPLETED) {
//TODO: some warning that this operation failed somehow //TODO: some warning that this operation failed somehow
// We have to disconnect the object persistence 'updated' signal // We have to disconnect the object persistence 'updated' signal
// and ask to save the next object: // and ask to save the next object:
UAVObject *obj = getObjectManager()->getObject(ObjectPersistence::NAME);
obj->disconnect(this); ObjectPersistence * objectPersistence = ObjectPersistence::GetInstance(getObjectManager());
queue.dequeue(); // We can now remove the object, it failed anyway. Q_ASSERT(objectPersistence);
UAVObject* obj = queue.dequeue(); // We can now remove the object, it failed anyway.
Q_ASSERT(obj);
objectPersistence->disconnect(this);
saveState = IDLE; saveState = IDLE;
emit saveCompleted(obj->getField("ObjectID")->getValue().toInt(), false); emit saveCompleted(obj->getObjID(), false);
// For now cause error message here to make sure user knows
QErrorMessage err;
err.showMessage("Saving object " + obj->getName() + " failed. Please try again");
err.exec();
saveNextObject(); saveNextObject();
} }
} }