QObject::installEventFilter(): Cannot filter events for objects in a different thread

2.9k Views Asked by At

I'm getting this error QObject::installEventFilter(): Cannot filter events for objects in a different thread. I have read that this error may arise when doing GUI operations not in main thread but in another thread. But my program is single threaded. I has one QMainwindow. Also I never install any event filters. Maybe Qt creates some other threads or event filters? I cant post the code because it is very huge and I dont know from where the error comes to post that part. So my question is how can I get more information about the error? Can I know exactly what does Qt try which cause the error. Also the error has random character: sometimes it is the error message, sometimes is Bus error, sometimes segmentation fault and sometimes there is not any problem.

With GDB I get the stack but the only source is main.c where is called application.exec(), the other frames are Qt libs

0  0x0000002a969983bc in QObject::installEventFilter () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
1  0x0000002a9625a75d in QAbstractItemView::commitData () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
2  0x0000002a96991d58 in QMetaObject::activate () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
3  0x0000002a9640404f in QAbstractItemDelegate::commitData () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
4  0x0000002a963184cf in QStyledItemDelegate::qt_static_metacall () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
5  0x0000002a9699820e in QObject::event () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
6  0x0000002a95c75e00 in QApplicationPrivate::notify_helper () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
7  0x0000002a95c7e6ff in QApplication::notify () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
8  0x0000002a9697a13b in QCoreApplication::notifyInternal () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
9  0x0000002a9697c42d in QCoreApplicationPrivate::sendPostedEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
10 0x0000002a969ae973 in ?? () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
11 0x000000315bc266bd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
12 0x000000315bc28397 in ?? () from /usr/lib64/libglib-2.0.so.0
13 0x000000315bc288eb in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
14 0x0000002a969af4f5 in QEventDispatcherGlib::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
15 0x0000002a95d2e6f9 in QGuiEventDispatcherGlib::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
16 0x0000002a96978f13 in QEventLoop::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
17 0x0000002a969793c1 in QEventLoop::exec () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
18 0x0000002a9697c76f in QCoreApplication::exec () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
19 0x000000000423122e in nlb::application::runGuiMode (argc=1, argv=0x7fbfffe888, args=
      {mode = nlb::application::Application::MODE_GUI, databasePath = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean
= 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_empty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, s
impletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x2a96bef7c0, static codecForCStrings = 0x0}, scriptPath = {static null = {<No data fields>}, static s
hared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_emp
ty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x6b8d780, static c
odecForCStrings = 0x0}, scriptArgs = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean = 0, simpletext = 0, righttoleft
= 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_empty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, simpletext = 0, righttoleft = 0, a
sciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x6b8d780, static codecForCStrings = 0x0}, help = false}, initialArgumentParsingSuccessed=true) at Isrc/NLBMain.C:366
1

There are 1 best solutions below

4
On

If you're using QtCreator set "Stop when qWarning() is called" option, that is located in Options -> Debugger -> GDB Extended.

After that start your app in debug mode (F5). When that warning is issued QtCreator will stop your app. Traverse through stack to find possible location of error.

If you don't use QtCreator, try to start your app under GDB and manually set breakpoint at qWarning().