[Interest] QMap crash when using QtConcurrent::blockingMapped()
Konstantin Shegunov
kshegunov at gmail.com
Thu Oct 26 22:58:46 CEST 2017
On Thu, Oct 26, 2017 at 11:11 PM, Jason H <jhihn at gmx.com> wrote:
>
> It sometimes works, sometimes doesn't.
Smells like a race.
> But in my software it seems to come from line 42:
> QList<QVector3D> hp = haystack_points[haystack_item];
>
This may be a write operation, beware of operator [] with maps, notice at
the ends of the docs:
"If the map contains no item with key key, the function inserts a
default-constructed value into the map with key key, and returns a
reference to it."
My advice is to declare your members in `PointsCompare` as const and take
it from there. The compiler will complain, but changing the access (e.g.
using `at()` instead of `[]`) to your members should fix it.
Maybe my use of a class with mapped() is wrong?
>
Not that I could see.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171026/8391895d/attachment.html>
More information about the Interest
mailing list