Commit 17b304c4 authored by Albert Astals Cid's avatar Albert Astals Cid

Do not call deleteLater on a null QObject

We don't always have a pairing handler for a given device link

Also change the assert not to trigger a warning in ubsan

Reviewed by Albert Vaca
parent 2008490a
......@@ -404,12 +404,15 @@ void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink)
{
const QString id = destroyedDeviceLink->property("deviceId").toString();
//qCDebug(KDECONNECT_CORE) << "deviceLinkDestroyed" << id;
Q_ASSERT(m_links.key(static_cast<LanDeviceLink*>(destroyedDeviceLink)) == id);
QMap< QString, LanDeviceLink* >::iterator linkIterator = m_links.find(id);
Q_ASSERT(linkIterator != m_links.end());
if (linkIterator != m_links.end()) {
Q_ASSERT(linkIterator.value() == destroyedDeviceLink);
m_links.erase(linkIterator);
m_pairingHandlers.take(id)->deleteLater();
auto pairingHandler = m_pairingHandlers.take(id);
if (pairingHandler) {
pairingHandler->deleteLater();
}
}
}
......
Markdown is supported
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