[Interest] ASSERT: "isDetached()" with multithreaded QVectors

James Ross-Smith jars121 at gmail.com
Thu Apr 26 23:09:27 CEST 2018


Morning all,

I make use of multiple (10+) QVectors in my multithreaded embedded
application, and I'm currently trying to troubleshoot and resolve the
following assertion:

ASSERT: "isDetached()" in file /opt/.../include/QtCore/qvector.h, line 386
Aborted

>From an initial discussion on the Qt forum, it would appear that mutliple
threads are trying to modify a QVector at the same time, with one thread
trying to modify a QVector which is already detached. Is that a correct
interpretation? Responders on the Qt forum recommended I posted to the
mailing list, as further clarification regarding this particular assertion
is better suited to the more detailed understanding within the mailing list
community.

Is there a way for me to determine which QVector or line of code is causing
the assertion? Further to that point, is there a generally recommended
approach to using QVectors in multithreaded applications? I've been told to
use QMutex, and have now implemented QMutexLockers but haven't had any
success, as I'm really not sure which QVector and/or from where the issue
originates. My other consideration was to not use QVectors, instead using
dedicated variables, rather than a QVector of variables.

i.e. currently I have valueVector = [value1, value2, value3], which could
be replaced with value1, value2 and value3 variables. My only issue with
this approach is I'm not sure how to modify the variable values with a
variable identifier like you can with a QVector.

i.e. valueVector[1] = value2. I'm not sure how I would do that if I passed
'n = 1' to a function, and wanted to modify value2. value(n+1) = x etc.

Any guidance on this issue would be greatly appreciated!

Cheers,
Jamie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180426/bfc8bf65/attachment.html>


More information about the Interest mailing list