我正在运行一个线程,但有时程序会死掉。我希望你能告诉我为什么退出。错误
检测到glibc / home / hsr / CMBU-build-desktop-Qt_4_8_1_in_PATH__System__Release / CMBU:损坏的双链表:0x00000000026192e0
回溯:
00400000-00437000 r-xp 00000000 08:01 2499001 / home / hsr / CMBU-build-desktop-Qt_4_8_1_in_PATH__System__Release / CMBU
00636000-00637000 r - p 00036000 08:01 2499001 / home / hsr / CMBU-build-desktop-Qt_4_8_1_in_PATH__System__Release / CMBU
00637000-00638000 rw-p 00037000 08:01 2499001 / home / hsr / CMBU-build-desktop-Qt_4_8_1_in_PATH__System__Release / CMBU
02410000-02c5f000 rw-p 00000000 00:00 0 [堆]
7fe2ff74d000-7fe2ffb72000 r - p 00000000 08:01 2755027 /usr/share/fonts/truetype/nanum/NanumGothic.ttf
7fe2ffb72000-7fe300000000 rw -s 00000000 00:04 6717449 / SYSV00000000(已删除)
7fe300000000-7fe300022000 rw-p 00000000 00:00 0
7fe300022000-7fe304000000 --- p 00000000 00:00 0
7fe304000000-7fe304132000 rw-p 00000000 00:00 0
7fe304132000-7fe308000000 --- p 00000000 00:00 0
7fe308000000-7fe308022000 rw-p 00000000 00:00 0
7fe308022000-7fe30c000000 --- p 00000000 00:00 0
7fe30c26c000-7fe30c2cc000 rw -s 00000000 00:04 6750219 / SYSV00000000(已删除)
7fe30c2cc000-7fe30c6e4000 r - p 00000000 08:01 2755028 /usr/share/fonts/truetype/nanum/NanumGothicBold.ttf
7fe30c6e4000-7fe30c6e5000 --- p 00000000 00:00 0
7fe30c6e5000-7fe30cee5000 rw-p 00000000 00:00 0
void Thread::run()
{
while (!stopped) {
if(messageStr==tr("A")) {
MainCMBU::ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime());
msleep(1000);
}
}
//std::cerr << qPrintable(messageStr);
stopped = false;
}
答案 0 :(得分:0)
在你正在做的线程中睡觉通常是糟糕的设计。
在Qt中,您无法从非GUI线程访问GUI线程元素。 GUI不是线程安全的。