ASSERT: "!isEmpty()" in file /opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qlist.h, line 341

遇到了如下的问题

SSERT: "!isEmpty()" in file /opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qlist.h, line 341
The program has unexpectedly finished.

这是我的相关代码

 qDebug() << "index:" << index << ":" << readport::q.head() << "..q.isEmpty:" << readport::q.isEmpty();
        if (!(readport::q.isEmpty()))
        {
            ui->customplot->graph(0)->addData(index, readport::q.dequeue());
        }

通过Debug发现问题是出在head和dequeue这两个函数
head会显示出堆栈的最上面一个数据
dequeue会读出堆栈的最上面一个数据,然后删掉它

这就导致我把堆栈上的数据都读完后,堆栈空了。而head着读不到数据,所以错了。

另外还有QT版本的问题。新版的QT就不会有这个问题。

ASSERT:
这是我的QT版本

你可能感兴趣的:(qt)