DiveShare patch
Thiago Macieira
thiago at macieira.org
Tue Oct 14 01:01:23 PDT 2014
On Tuesday 14 October 2014 09:41:36 Salvo Tomaselli wrote:
> Hello,
>
> > I only have one issue: your code leaks memory if the user clicks the
> > "Upload dive data" button twice before the request finishes, as in
> > doUpload you simply assign the new QNetworkReply object to this->reply.
>
> The button becomes invisible when it's pressed, so it can't really be
> pressed twice in a row.
Thanks, I didn't see that in your patch.
> > 1) make the function take a const QByteArray &data
>
> Done, but I think QByteArray internally shares memory so it only copies on
> write.
It does, but the const reference saves us one atomic increment and one atomic
decrement anyway. Maybe it's negligible, but it's good coding practice to
always use them like that.
> One thing that makes me uneasy now is this:
>
> reply = WebServices::manager()->put(request, json_data);
> QObject::connect(reply, SIGNAL(finished()), this, SLOT(finishedSlot()));
>
> What if the signal is emitted before the connect?
It isn't, by design. The reply can only finish once you return to the event
loop.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the subsurface
mailing list