[Interest] QMap crash when using QtConcurrent::blockingMapped()

Elvis Stansvik elvstone at gmail.com
Fri Oct 27 08:46:26 CEST 2017


Den 27 okt. 2017 8:45 fm skrev "Elvis Stansvik" <elvstone at gmail.com>:

Den 26 okt. 2017 10:11 em skrev "Jason H" <jhihn at gmx.com>:

This is the first time I'm trying to use QMap with QtConcurrent, and
blockingMapped().

It sometimes works, sometimes doesn't. I've created a minimal test case
that seems to crash in the same way. It seems to crash in varying places.
namely:
qmap.h:
template <class Key> inline bool qMapLessThanKey(const Key &key1, const Key
&key2)
{
    return key1 < key2;
}

But in my software it seems to come from line 42:
QList<QVector3D> hp = haystack_points[haystack_item];

I've already haystack_points to a 1001 item map, I think something else has
deleted it?

Maybe my use of a class with mapped() is wrong?


Not sure if this is your problem here, but it looks like you're using the
same QMap from multiple threads (the one stored in your function).


s/function/functor/

Elvis


QMap isn't thread safe, so I don't think your use is guaranteed to be safe,
even if you're only reading.

Could be wrong of course and on my phone atm so awkward to check.

Elvis



Any help is appreciated.


_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171027/68870a6d/attachment.html>


More information about the Interest mailing list