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
This commit is contained in:
parent
2008490ad9
commit
17b304c42a
1 changed files with 5 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue