[Qt-interest] Treating User defined type as QVariant via void*

Thiago Macieira thiago at kde.org
Wed Sep 22 13:12:28 CEST 2010


Em Quarta-feira 22 Setembro 2010, às 12:46:47, Stephen Kelly escreveu:
> You never use the macro Q_DECLARE_METATYPE
> 
> Have a read through the docs for QVariant and QMetaType.

By the way, if you declare Node* as a metatype, you'll be storing the pointer 
*value* in the variant, not the pointed contents.

If you then proceed to save the value to permanent storage (disk) or share it 
with another process, you'll recover a pointer that is completely invalid. Do 
not attempt to dereference it.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Qt Developer Days 2010  -  Munich Oct 11-13  -  San Francisco Nov 1-3
For more information and to register: http://qt.nokia.com/qtdevdays2010
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100922/22bb7e2c/attachment.bin 


More information about the Qt-interest-old mailing list