Hi,
I am developing QT based non-GUI code (using QT events, shared memory, logging, etc). I want to unit test this code using boost unit test framework. The tests all pass ok, but when the test suite ends there are memory leaks. I think this is caused by the QT message loop not being run so QObject (QFile, QDir, etc) instances are not being freed. What I can't figure out is how to run QCoreApplication.
I do not have access to the program main function - it is hidden away inside boost somewhere. How do I call QCoreApplication so that QObjects are properly destroyed and the boost test framework properly runs?
I am using:
QT: 4.6.2
Boost 1.42
Windows Visual Studio 2008 SP1 Version 9.0.30729.1
Microsoft .NET 3.5 SP1
Windows XP SP3
I'm calling this from the beginning of test case 1 - it never returns.
Qt Code:
int initQT() { BOOST_TEST_MESSAGE("Initializing QT..."); // fake some data for QCodeApplication int argc = 1; char argv1[] = "IRL_QT.exe"; char* argv[] = {argv1, NULL}; return qca.exec(); }To copy to clipboard, switch view to plain text mode
With memory leaks errors:
1>Detected memory leaks!
1>Dumping objects ->
1>{253997} normal block at 0x0091D968, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{253996} normal block at 0x0091C0A8, 4 bytes long.
1> Data: <h > 68 D9 91 00
1>{252618} normal block at 0x00910928, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{252617} normal block at 0x003EFB60, 4 bytes long.
1> Data: <( > 28 09 91 00
1>{251898} normal block at 0x00912FC8, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{251897} normal block at 0x00912F98, 4 bytes long.
1> Data: < / > C8 2F 91 00
1>{251677} normal block at 0x00913030, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{251676} normal block at 0x009112F8, 4 bytes long.
1> Data: <00 > 30 30 91 00
1>{221032} normal block at 0x0092B108, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{221011} normal block at 0x0092A0D8, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{220990} normal block at 0x009290A8, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{220969} normal block at 0x00928078, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{220948} normal block at 0x00927048, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{220927} normal block at 0x00926018, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{198116} normal block at 0x009176A8, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{198095} normal block at 0x00916678, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{198074} normal block at 0x00913160, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{129667} normal block at 0x00916630, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{129666} normal block at 0x00915358, 4 bytes long.
1> Data: <0f > 30 66 91 00
1>{128143} normal block at 0x00910528, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{128142} normal block at 0x003E79F0, 4 bytes long.
1> Data: <( > 28 05 91 00
1>{127285} normal block at 0x00924FE8, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{127264} normal block at 0x009141A0, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{127243} normal block at 0x009113B8, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{119426} normal block at 0x00912C88, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{119425} normal block at 0x003E7570, 4 bytes long.
1> Data: < , > 88 2C 91 00
1>{117904} normal block at 0x0091C6B0, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{117903} normal block at 0x0091AFF8, 4 bytes long.
1> Data: < > B0 C6 91 00
1>{94218} normal block at 0x0091B028, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{94197} normal block at 0x00919F48, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{94176} normal block at 0x009105D0, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{94175} normal block at 0x003E81A0, 4 bytes long.
1> Data: < > D0 05 91 00
1>{94174} normal block at 0x00918F18, 4097 bytes long.
1> Data: < > 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
1>{47534} normal block at 0x00910980, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{47533} normal block at 0x009101B8, 4 bytes long.
1> Data: < > 80 09 91 00
1>{1011} normal block at 0x00910EA0, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{1010} normal block at 0x003E73C8, 4 bytes long.
1> Data: < > A0 0E 91 00
1>{766} normal block at 0x00910890, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{765} normal block at 0x003E83A8, 4 bytes long.
1> Data: < > 90 08 91 00
1>{764} normal block at 0x00910638, 552 bytes long.
1> Data: < H > 83 00 00 00 83 00 00 00 48 06 91 00 CD CD CD CD
1>{753} normal block at 0x00910400, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{752} normal block at 0x00910360, 116 bytes long.
1> Data: <xT)g( 9g> 78 54 29 67 28 03 91 00 00 00 00 00 C0 E8 39 67
1>{751} normal block at 0x00910328, 8 bytes long.
1> Data: <8T)g` > 38 54 29 67 60 03 91 00
1>{750} normal block at 0x009102E0, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{749} normal block at 0x00910298, 24 bytes long.
1> Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
1>{748} normal block at 0x00910230, 56 bytes long.
1> Data: < ( > 01 00 00 00 28 03 91 00 00 CD CD CD 00 00 00 00
Thanks,
Clarence
Bookmarks