QObject :: installEventFilter():无法过滤不同线程中对象的事件

时间:2013-08-13 11:56:27

标签: c++ qt events segmentation-fault bus-error

我收到此错误QObject::installEventFilter(): Cannot filter events for objects in a different thread。我已经读过,当不在主线程中而是在另一个线程中执行GUI操作时,可能会出现此错误。但我的程序是单线程的。我有一个QMainwindow。我也从不安装任何事件过滤器。也许Qt创建了一些其他线程或事件过滤器?我无法发布代码,因为它非常庞大,我不知道错误来自哪个部分。 所以我的问题是如何才能获得有关错误的更多信息?我能确切地知道Qt尝试导致错误的原因。此错误也是随机字符:有时它是错误消息,有时是Bus error,有时是segmentation fault,有时候没有任何问题。

使用GDB我得到堆栈,但唯一的来源是main.c,其中名为application.exec(),其他框架是Qt库

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 个答案:

答案 0 :(得分:4)

如果你正在使用QtCreator设置“调用qWarning()时停止”选项,它位于选项 - &gt;调试器 - &gt; GDB扩展。

之后在调试模式下启动您的应用程序(F5)。发出该警告后,QtCreator将停止您的应用。遍历堆栈以找到错误的可能位置。

如果您不使用QtCreator,请尝试在GDB下启动您的应用,并在qWarning()手动设置断点。