Qt heap memory corruption
I'm writing a Qt 4.6 application (without the qt designer) and when I close the program I get this error from Visual Studio:
Windows has triggered a breakpoint in Test.exe.
This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Test.exe has focus.
The output window may have more diagnostic information.
Here is the source code:
Main.cpp
http://pastebin.com/DeUvZSHUTesterWindow.h
http://pastebin.com/SEVr8x40Teste开发者_运维知识库rWindow.cpp
http://pastebin.com/MYUtZZGwDevice.h
http://pastebin.com/bXKxVrmWDevice.cpp
http://pastebin.com/H1kMcResExtWiiMote.h
http://pastebin.com/uX3HT9YwExtWiiMote.cpp
http://pastebin.com/p2TKZdHv
(You can't compile it, I can't share the used library)
What's wrong?
In ExtWiiMote.h
you declared
QLabel* dots[3][3];
and in the ExtWiiMote.cpp
you use dots[3][0]...
.
Fix dots
array size and probably you'll be fine.
I had the same error last month but since lots of different problems can cause it, I'm not sure my answer will help you.
This was caused by a derived class (Child) without virtual destructor. The error pops up each time the debugger was entering the destructor of Child. Since I'm at work and can not access to the website to get source code I can not check this.
Hope this may help you
精彩评论