[Qt-interest] QHash::const_iterator not reentrant?
BOUCARD Olivier
boucard_olivier at yahoo.fr
Thu Aug 18 18:56:23 CEST 2011
Hi everybody,
I have a problem with QHash and const_iterator.
I have two QHash instance with their respective const_iterator in two different thread.
And it cause crash when I iterate on both at the same time.
I have made a little research and found that there is a static function QHashData::Node *QHashData::nextNode(Node *node).
And I think the problem come from here, the code seems not reentrant:
QHashData::Node *QHashData::nextNode(Node *node)
{
union {
Node *next;
Node *e;
QHashData *d;
};
next = node->next;
Q_ASSERT_X(next, "QHash", "Iterating beyond end()");
if (next->next)
return next;
int start = (node->h % d->numBuckets) + 1;
Node **bucket = d->buckets + start;
int n = d->numBuckets - start;
while (n--) {
if (*bucket != e)
return *bucket;
++bucket;
}
return e;
}
Someone could confirm that, please.
Any alternative, workaround, ... if it is confirmed?
Thank you.
Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110818/31cae606/attachment.html
More information about the Qt-interest-old
mailing list