1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-05 21:52:10 +01:00

GCS - Changes reload button behavior, now loads data from persistence memory.

This commit is contained in:
zedamota 2012-05-07 14:02:58 +01:00
parent 40e215ae27
commit 9481be90af
2 changed files with 18 additions and 4 deletions

View File

@ -31,7 +31,7 @@
/** /**
* Constructor * Constructor
*/ */
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);") ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL)
{ {
pm = ExtensionSystem::PluginManager::instance(); pm = ExtensionSystem::PluginManager::instance();
objManager = pm->getObject<UAVObjectManager>(); objManager = pm->getObject<UAVObjectManager>();
@ -175,6 +175,10 @@ ConfigTaskWidget::~ConfigTaskWidget()
if(oTw) if(oTw)
delete oTw; delete oTw;
} }
if(timeOut)
{
delete timeOut;
}
} }
void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) void ConfigTaskWidget::saveObjectToSD(UAVObject *obj)
@ -780,7 +784,7 @@ void ConfigTaskWidget::reloadButtonClicked()
if(!list) if(!list)
return; return;
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( getObjectManager()->getObject(ObjectPersistence::NAME) ); ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( getObjectManager()->getObject(ObjectPersistence::NAME) );
QTimer * timeOut=new QTimer(this); timeOut=new QTimer(this);
QEventLoop * eventLoop=new QEventLoop(this); QEventLoop * eventLoop=new QEventLoop(this);
connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit())); connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit()));
connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit()));
@ -799,13 +803,22 @@ void ConfigTaskWidget::reloadButtonClicked()
eventLoop->exec(); eventLoop->exec();
if(timeOut->isActive()) if(timeOut->isActive())
{ {
oTw->object->requestUpdate();
setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited); setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited);
} }
timeOut->stop(); timeOut->stop();
} }
} }
delete eventLoop; if(eventLoop)
delete timeOut; {
delete eventLoop;
eventLoop=NULL;
}
if(timeOut)
{
delete timeOut;
timeOut=NULL;
}
} }
/** /**

View File

@ -164,6 +164,7 @@ private:
void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale);
QString outOfLimitsStyle; QString outOfLimitsStyle;
QTimer * timeOut;
protected slots: protected slots:
virtual void disableObjUpdates(); virtual void disableObjUpdates();
virtual void enableObjUpdates(); virtual void enableObjUpdates();