QCoapClient: delete the old connection in its own thread


setConnection() deleted the current connection although it, and its
QUdpSocket child, live in the running worker thread. Deleting a QObject
from another thread races with that thread delivering events to it.
Since qtbase commit 1e0b940, ~QObject() posts an event to cross-thread
senders, which made tst_QCoapClient crash with a use-after-free.

Fixes: QTBUG-149883
Pick-to: 6.12 6.11 6.8
Change-Id: Id016e0c38b36c57c728aa6c6825e0f37cdde2041
Reviewed-by: Mate Barany <mate.barany@qt.io>
commit591447a01be4aeadb9eb85578b51c34e4f0d8e1d
parent51970ba424895bd06119389c4d95b70912f080e5
authorDavid Faure <david.faure@kdab.com>
committerDavid Faure <david.faure@kdab.com>
commit timeThu, 3 Sep 2026 13:59:21 +0000