diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 9ca77badf..a6dda376b 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -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(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(); + } } }