[Qt-interest] A new (?) const-correct way to create a Ui object and do setupUi
Thiago Macieira
thiago at kde.org
Tue Feb 8 13:13:07 CET 2011
Em terça-feira, 8 de fevereiro de 2011, às 13:32:16, Nikos Chantziaras
escreveu:
> On 02/08/2011 01:00 PM, Thiago Macieira wrote:
> > [...] And how do you delete the reference afterwards?
>
> You are not allowed to delete objects that were not created with "new":
>
> QObject* obj1 = new QObject;
>
> You can delete obj1. However:
>
> QObject obj2;
>
> You cannot delete obj2. For the same reason, you do not delete
> references to obj2.
And that still has nothing to do with the OP message.
See the attached program. Here's its valgrind output:
==18525== Memcheck, a memory error detector
==18525== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==18525== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==18525== Command: /tmp/reference
==18525==
==18525==
==18525== HEAP SUMMARY:
==18525== in use at exit: 1 bytes in 1 blocks
==18525== total heap usage: 1 allocs, 0 frees, 1 bytes allocated
==18525==
==18525== 1 bytes in 1 blocks are definitely lost in loss record 1 of 1
==18525== at 0x4007849: operator new(unsigned int) (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==18525== by 0x8048438: ReferencingClass::ReferencingClass()
(reference.cpp:16)
==18525== by 0x804845B: main (reference.cpp:26)
==18525==
==18525== LEAK SUMMARY:
==18525== definitely lost: 1 bytes in 1 blocks
==18525== indirectly lost: 0 bytes in 0 blocks
==18525== possibly lost: 0 bytes in 0 blocks
==18525== still reachable: 0 bytes in 0 blocks
==18525== suppressed: 0 bytes in 0 blocks
==18525==
==18525== For counts of detected and suppressed errors, rerun with: -v
==18525== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 13 from 6)
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reference.cpp
Type: text/x-c++src
Size: 373 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110208/776c4292/attachment.bin
-------------- 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/20110208/776c4292/attachment-0001.bin
More information about the Qt-interest-old
mailing list