From 9481be90af580ffdc5b8838451b38becaf86ab0a Mon Sep 17 00:00:00 2001 From: zedamota Date: Mon, 7 May 2012 14:02:58 +0100 Subject: [PATCH] GCS - Changes reload button behavior, now loads data from persistence memory. --- .../uavobjectwidgetutils/configtaskwidget.cpp | 21 +++++++++++++++---- .../uavobjectwidgetutils/configtaskwidget.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 51bafbb2d..8bd2fe7b5 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -31,7 +31,7 @@ /** * 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(); objManager = pm->getObject(); @@ -175,6 +175,10 @@ ConfigTaskWidget::~ConfigTaskWidget() if(oTw) delete oTw; } + if(timeOut) + { + delete timeOut; + } } void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) @@ -780,7 +784,7 @@ void ConfigTaskWidget::reloadButtonClicked() if(!list) return; ObjectPersistence* objper = dynamic_cast( getObjectManager()->getObject(ObjectPersistence::NAME) ); - QTimer * timeOut=new QTimer(this); + timeOut=new QTimer(this); QEventLoop * eventLoop=new QEventLoop(this); connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit())); @@ -799,13 +803,22 @@ void ConfigTaskWidget::reloadButtonClicked() eventLoop->exec(); if(timeOut->isActive()) { + oTw->object->requestUpdate(); setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited); } timeOut->stop(); } } - delete eventLoop; - delete timeOut; + if(eventLoop) + { + delete eventLoop; + eventLoop=NULL; + } + if(timeOut) + { + delete timeOut; + timeOut=NULL; + } } /** diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index a0e1feb7b..f835a417d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -164,6 +164,7 @@ private: void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); QString outOfLimitsStyle; + QTimer * timeOut; protected slots: virtual void disableObjUpdates(); virtual void enableObjUpdates();