Commit 47bc8b9b authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Avoid creating Adapter objects for dbusPath that we already have

CCBUG:314356
parent 0fa1e2be
......@@ -161,6 +161,11 @@ Adapter *Manager::Private::findUsableAdapter()
void Manager::Private::_k_adapterAdded(const QDBusObjectPath &objectPath)
{
qDebug() << "Added: " << objectPath.path();
if (m_adaptersHash.contains(objectPath.path())) {
qDebug() << "Already in the adapterHash";
return;
}
Adapter *const adapter = new Adapter(objectPath.path(), m_q);
connect(adapter, SIGNAL(poweredChanged(bool)), m_q, SLOT(_k_adapterPoweredChanged(bool)));
......@@ -301,7 +306,7 @@ Adapter *Manager::defaultAdapter()
if (!d->m_defaultAdapter) {
const QString adapterPath = d->m_bluezManagerInterface->DefaultAdapter().value().path();
if (!adapterPath.isEmpty()) {
if (!adapterPath.isEmpty() && !d->m_adaptersHash.contains(adapterPath)) {
d->m_defaultAdapter = new Adapter(adapterPath, const_cast<Manager*>(this));
connect(d->m_defaultAdapter, SIGNAL(poweredChanged(bool)), SLOT(_k_adapterPoweredChanged(bool)));
d->m_adaptersHash.insert(adapterPath, d->m_defaultAdapter);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment