1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

Improvements in suspendPolling/resumePolling in the connection manager even

if a connection plugin does not have devices connected when called.



git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2388 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-01-12 07:43:02 +00:00 committed by edouard
parent 0f965df11e
commit dda5d55ffa
2 changed files with 14 additions and 19 deletions

View File

@ -117,13 +117,22 @@ void ConnectionManager::objectAdded(QObject *obj)
//register devices and populate CB //register devices and populate CB
devChanged(connection); devChanged(connection);
// Keep track of the registration to be able to tell plugins
// to do things
m_connectionsList.append(connection);
QObject::connect(connection, SIGNAL(availableDevChanged(IConnection *)), QObject::connect(connection, SIGNAL(availableDevChanged(IConnection *)),
this, SLOT(devChanged(IConnection*))); this, SLOT(devChanged(IConnection*)));
} }
void ConnectionManager::aboutToRemoveObject(QObject *obj) void ConnectionManager::aboutToRemoveObject(QObject *obj)
{ {
Q_UNUSED(obj); //Check if a plugin added a connection object to the pool
IConnection *connection = Aggregation::query<IConnection>(obj);
if (!connection)
return;
if (m_connectionsList.contains(connection))
m_connectionsList.removeAt(m_connectionsList.indexOf(connection));
} }
/** /**
@ -250,18 +259,11 @@ void ConnectionManager::unregisterAll(IConnection *connection)
/** /**
* Tells every connection plugin to stop polling for devices if they * Tells every connection plugin to stop polling for devices if they
* are doing that. * are doing that.
*
*/ */
void ConnectionManager::suspendPolling() void ConnectionManager::suspendPolling()
{ {
QList<IConnection*> connections; foreach (IConnection* cnx, m_connectionsList) {
connections.clear();
for(QLinkedList<devListItem>::iterator iter = m_devList.begin();
iter != m_devList.end(); iter++ ){
if (!connections.contains(iter->connection))
connections.append(iter->connection);
}
foreach (IConnection* cnx, connections) {
cnx->suspendPolling(); cnx->suspendPolling();
} }
} }
@ -272,15 +274,7 @@ void ConnectionManager::suspendPolling()
*/ */
void ConnectionManager::resumePolling() void ConnectionManager::resumePolling()
{ {
QList<IConnection*> connections; foreach (IConnection* cnx, m_connectionsList) {
connections.clear();
for(QLinkedList<devListItem>::iterator iter = m_devList.begin();
iter != m_devList.end(); iter++ ){
if (!connections.contains(iter->connection))
connections.append(iter->connection);
}
foreach (IConnection* cnx, connections) {
cnx->resumePolling(); cnx->resumePolling();
} }
} }

View File

@ -94,6 +94,7 @@ protected:
QComboBox *m_availableDevList; QComboBox *m_availableDevList;
QPushButton *m_connectBtn; QPushButton *m_connectBtn;
QLinkedList<devListItem> m_devList; QLinkedList<devListItem> m_devList;
QList<IConnection*> m_connectionsList;
//currently connected connection plugin //currently connected connection plugin
devListItem m_connectionDevice; devListItem m_connectionDevice;