[Development] Qt 5: Warning using QImage as QtConcurrent::mapped return type
Olivier Goffart
olivier at woboq.com
Sun Sep 30 18:50:49 CEST 2012
On Saturday 29 September 2012 15:53:15 Stephen Chu wrote:
> The following code generates warning about memcpy on object type:
>
> QList<QImage> images;
> QList<QImage> future = QtConcurrent::blockingMapped(images, scaled);
>
> The warning:
>
> In file included from /Qt/5.0/qtbase/include/QtCore/qvector.h:1:
> /Qt/5.0/qtbase/include/QtCore/../../src/corelib/tools/qvector.h:459:56:
> warning: source of this 'memcpy' call is a pointer to dynamic class
> 'QImage'; vtable pointer will be copied [-Wdynamic-class-memaccess]
>
> ::memcpy(static_cast<void *>(dst), srcBegin,
>
> (srcEnd - srcBegin) * sizeof(T));
> ~~~~~~~~ ^
>
> It seems that Qt thinks QImage is a POD type?
Because QImage is registered as Q_MOVABLE_TYPE.
(It is the case since Q_DECLARE_SHARED does that)
It shuld be safe in that case, because virtual table pointer should be
movable, and we know that we have arrays of QImage and not the derived type.
But this warning may be annoying. Maybe should we work around it
--
Olivier
Woboq - Qt services and support - http://woboq.com
More information about the Development
mailing list