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:
parent
52a3d0079e
commit
a6e9235888
@ -32,7 +32,7 @@
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* 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();
|
pm = ExtensionSystem::PluginManager::instance();
|
||||||
objManager = pm->getObject<UAVObjectManager>();
|
objManager = pm->getObject<UAVObjectManager>();
|
||||||
@ -127,7 +127,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
|
|||||||
Q_ASSERT(obj);
|
Q_ASSERT(obj);
|
||||||
objectUpdates.insert(obj,true);
|
objectUpdates.insert(obj,true);
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*)));
|
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)
|
if(!field.isEmpty() && obj)
|
||||||
_field = obj->getField(QString(field));
|
_field = obj->getField(QString(field));
|
||||||
@ -258,6 +258,9 @@ void ConfigTaskWidget::populateWidgets()
|
|||||||
*/
|
*/
|
||||||
void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj)
|
void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj)
|
||||||
{
|
{
|
||||||
|
if (!allowWidgetUpdates)
|
||||||
|
return;
|
||||||
|
|
||||||
bool dirtyBack=dirty;
|
bool dirtyBack=dirty;
|
||||||
emit refreshWidgetsValuesRequested();
|
emit refreshWidgetsValuesRequested();
|
||||||
foreach(objectToWidget * ow,objOfInterest)
|
foreach(objectToWidget * ow,objOfInterest)
|
||||||
@ -452,10 +455,10 @@ bool ConfigTaskWidget::isDirty()
|
|||||||
*/
|
*/
|
||||||
void ConfigTaskWidget::disableObjUpdates()
|
void ConfigTaskWidget::disableObjUpdates()
|
||||||
{
|
{
|
||||||
|
allowWidgetUpdates = false;
|
||||||
foreach(objectToWidget * obj,objOfInterest)
|
foreach(objectToWidget * obj,objOfInterest)
|
||||||
{
|
{
|
||||||
if(obj->object)
|
if(obj->object)disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)));
|
||||||
disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -463,10 +466,11 @@ void ConfigTaskWidget::disableObjUpdates()
|
|||||||
*/
|
*/
|
||||||
void ConfigTaskWidget::enableObjUpdates()
|
void ConfigTaskWidget::enableObjUpdates()
|
||||||
{
|
{
|
||||||
|
allowWidgetUpdates = true;
|
||||||
foreach(objectToWidget * obj,objOfInterest)
|
foreach(objectToWidget * obj,objOfInterest)
|
||||||
{
|
{
|
||||||
if(obj->object)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -145,6 +145,7 @@ private slots:
|
|||||||
void reloadButtonClicked();
|
void reloadButtonClicked();
|
||||||
private:
|
private:
|
||||||
bool isConnected;
|
bool isConnected;
|
||||||
|
bool allowWidgetUpdates;
|
||||||
QStringList objectsList;
|
QStringList objectsList;
|
||||||
QList <objectToWidget*> objOfInterest;
|
QList <objectToWidget*> objOfInterest;
|
||||||
ExtensionSystem::PluginManager *pm;
|
ExtensionSystem::PluginManager *pm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user