QCoapClient: destroy the protocol and connection in the worker thread


QCoapClientPrivate moves the protocol and connection objects to a worker
thread, so they - and their children, such as QCoapInternalRequest's
retransmission timers and QCoapQUdpConnection's QUdpSocket - live in
that thread. The destructor however deleted them from the client's
thread, after quit()/wait() had stopped the worker.

Destroying a QObject from a thread other than the one it lives in is
undefined behavior. In practice it emitted warnings such as
"QObject::~QObject: Timers cannot be stopped from another thread".

Instead, let's use deleteLater() and let the worker thread destroy these
objects itself: QThread drains DeferredDelete events when its event loop
stops, i.e. inside quit()/wait().

Pick-to: 6.12 6.11 6.8
Task-number: QTBUG-149883
Change-Id: I95fa734d5f3aaffd38c0fffd36fc063a085caecd
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
commit1b70ad662edce5f89f91c9a803936e8229f4e6da
parentb8f1d215ac0b60f81019f3c274b686bb72059385
authorThiago Macieira <thiago.macieira@intel.com>
committerThiago Macieira <thiago.macieira@intel.com>
commit timeSat, 5 Sep 2026 11:32:56 +0000