[Development] QtCoap: QNAM-like API or not

Ville Voutilainen ville.voutilainen at gmail.com
Sun Jan 14 20:51:41 CET 2018


On 14 January 2018 at 19:49, Adrien LERAVAT <aleravat at witekio.com> wrote:
> With the clear drawback of explicit memory management needed by users. We
> made
>
> some tests with a container/RAII object for the reply, and it seems fine,
> but before
>
> moving forward in this limited timeframe, we wanted to have your feedback.
>
> Sample below:
>
>
> \code
>
> QCoapClient client;
>
> QCoapRequest request = client.get(QUrl("1.2.3.4:5683"));
>
> connect(request.reply(), &QCoapReply::finished, this, &MyClass::onFinished);
>
> ...
>
> MyClass::onFinished(const QCoapRequest &request)
>
> {
>
>     qWarning() << request.reply()->readAll();
>
> }
>
> \endcode
>
>
> In that case, the QCoapReply life is managed with a
> QSharedPointer<QCoapReply> in the request.
>
> QCoapRequest does not inherit from QObject. Anyone sees a problem with this
> approach?


Doing automatic cleanup is certainly an improvement, but in addition
to that, I think it's useful if
the user can explicitly cleanup as well, as soon as she's done with
the reply, without waiting for the lifetime
of the request to end.



More information about the Development mailing list