1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Make the connections in the config gadget unique and add a flag to make sure

the refreshWidgetValues is never caleld after disabling updates
This commit is contained in:
James Cotton 2012-05-28 14:09:23 -05:00
parent 52a3d0079e
commit a6e9235888
2 changed files with 10 additions and 5 deletions

View File

@ -32,7 +32,7 @@
/**
* Constructor
*/
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL)
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL),allowWidgetUpdates(true)
{
pm = ExtensionSystem::PluginManager::instance();
objManager = pm->getObject<UAVObjectManager>();
@ -127,7 +127,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
Q_ASSERT(obj);
objectUpdates.insert(obj,true);
connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*)));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection);
}
if(!field.isEmpty() && obj)
_field = obj->getField(QString(field));
@ -258,6 +258,9 @@ void ConfigTaskWidget::populateWidgets()
*/
void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj)
{
if (!allowWidgetUpdates)
return;
bool dirtyBack=dirty;
emit refreshWidgetsValuesRequested();
foreach(objectToWidget * ow,objOfInterest)
@ -452,10 +455,10 @@ bool ConfigTaskWidget::isDirty()
*/
void ConfigTaskWidget::disableObjUpdates()
{
allowWidgetUpdates = false;
foreach(objectToWidget * obj,objOfInterest)
{
if(obj->object)
disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
if(obj->object)disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)));
}
}
/**
@ -463,10 +466,11 @@ void ConfigTaskWidget::disableObjUpdates()
*/
void ConfigTaskWidget::enableObjUpdates()
{
allowWidgetUpdates = true;
foreach(objectToWidget * obj,objOfInterest)
{
if(obj->object)
connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)));
connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection);
}
}
/**

View File

@ -145,6 +145,7 @@ private slots:
void reloadButtonClicked();
private:
bool isConnected;
bool allowWidgetUpdates;
QStringList objectsList;
QList <objectToWidget*> objOfInterest;
ExtensionSystem::PluginManager *pm;