View Full Version : Got a weird error while executing my programs

25th November 2011, 21:19
I'm a college student (so yeah i'm newb) and i have an error that i've never encountered.

Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc

Program received signal SIGABRT, Aborted.
0x00007ffff5f8bd05 in raise () from /lib/x86_64-linux-gnu/libc.so.6

The stacktrace from gdb return me :

#0 0x00007ffff5f8bd05 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff5f8fab6 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff68426dd in __gnu_cxx::__verbose_terminate_handler() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff6840926 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff6840953 in std::terminate() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff6840aa6 in __cxa_rethrow ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff6e05bb2 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#7 0x00007ffff6e09ecb in QCoreApplication::exec() ()
from /usr/lib/libQtCore.so.4
#8 0x0000000000404d09 in main ()

here's the whole class: http://pastie.org/2921209

Here's some info I found when trying:
When I comment the line #26 setCentralWidget(widTurtle);

the programme will just execute fine.

26th November 2011, 06:37
std::bad_alloc is thrown by the new operator when insufficient memory is available or there was some other issue with memory.

If you build a debug version of your code, and run the program in the debugger you should be able to inspect the value of all your member variables etc. I cannot see an obvious issue with the Qt UI construction. Have you tried with the Turtle stuff commented out?