QOpenGLWidget with QPainter coredump
Solved
General and Desktop
-
I was trying to calling QPainter after OpenGL rendering for tangram-es. and then it's coredump
void GLWidget::paintGL() { QPainter painter; painter.begin(this); painter.beginNativePainting(); tangramProcessNetworkQueue(); double timeNow = currentTime(); tangramUpdate(map, timeNow - lastTime); lastTime = timeNow; tangramRender(map); painter.endNativePainting(); painter.setPen(Qt::black); painter.drawText(20, 40, QStringLiteral(" paintGL calls / s")); painter.end(); update(); }
The stack trace is:
Program received signal SIGSEGV, Segmentation fault. 0x00007fffe4e24ec0 in ?? () from /usr/lib64/dri/swrast_dri.so #0 0x00007fffe4e24ec0 in ?? () from /usr/lib64/dri/swrast_dri.so #1 0x00007fffe4e3af58 in ?? () from /usr/lib64/dri/swrast_dri.so #2 0x00007fffe4e240ec in ?? () from /usr/lib64/dri/swrast_dri.so #3 0x00007fffe4e24474 in ?? () from /usr/lib64/dri/swrast_dri.so #4 0x00007ffff6ba2bfd in ?? () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Gui.so.5 #5 0x00007ffff6ba4284 in QOpenGL2PaintEngineEx::drawTextItem(QPointF const&, QTextItem const&) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Gui.so.5 #6 0x00007ffff6b01905 in ?? () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Gui.so.5 #7 0x00007ffff6b02380 in QPainter::drawText(QPointF const&, QString const&, int, int) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Gui.so.5 #8 0x000000000040c47d in QPainter::drawText (this=0x7fffffffce50, x=20, y=40, s=...) at ../../../../Qt5.7.0/5.7/gcc_64/include/QtGui/qpainter.h:890 #9 0x0000000000409cd1 in GLWidget::paintGL (this=0x6620b0) at ../../opengl/qopenglwidget/glwidget.cpp:346 #10 0x00007ffff70e2a25 in ?? () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #11 0x00007ffff70c2b78 in QWidget::event(QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #12 0x00007ffff707d52c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #13 0x00007ffff7084220 in QApplication::notify(QObject*, QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #14 0x00007ffff6091ae0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ---Type <return> to continue, or q <return> to quit--- () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Core.so.5 #15 0x00007ffff70bb54a in QWidgetPrivate::sendPaintEvent(QRegion const&) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #16 0x00007ffff70e28c1 in QOpenGLWidget::resizeEvent(QResizeEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #17 0x00007ffff70c300e in QWidget::event(QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #18 0x00007ffff707d52c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #19 0x00007ffff7084220 in QApplication::notify(QObject*, QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #20 0x00007ffff6091ae0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Core.so.5 #21 0x00007ffff70bb4d2 in QWidgetPrivate::sendPendingMoveAndResizeEvents(bool, bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #22 0x00007ffff70bf9a6 in QWidgetPrivate::show_helper() () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #23 0x00007ffff70bf8f0 in QWidgetPrivate::showChildren(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #24 0x00007ffff70bf9c2 in QWidgetPrivate::show_helper() () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #25 0x00007ffff70c2635 in QWidget::setVisible(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 ---Type <return> to continue, or q <return> to quit--- #26 0x00007ffff70bf958 in QWidgetPrivate::showChildren(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #27 0x00007ffff70bf9c2 in QWidgetPrivate::show_helper() () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #28 0x00007ffff70c2635 in QWidget::setVisible(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #29 0x00007ffff70bf958 in QWidgetPrivate::showChildren(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #30 0x00007ffff70bf9c2 in QWidgetPrivate::show_helper() () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #31 0x00007ffff70c2635 in QWidget::setVisible(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #32 0x00007ffff70bf958 in QWidgetPrivate::showChildren(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #33 0x00007ffff70bf9c2 in QWidgetPrivate::show_helper() () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #34 0x00007ffff70c2635 in QWidget::setVisible(bool) () from /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 #35 0x0000000000407df6 in main (argc=1, argv=0x7fffffffdba8) at ../../opengl/qopenglwidget/main.cpp:69
So what's going on after all?
-
@lygstate said in QOpenGLWidget with QPainter coredump:
QPainter::drawText (this=0x7fffffffce50, x=20, y=40, s=...) at ../../../../Qt5.7.0/5.7/gcc_64/include/QtGui/qpainter.h:890
This
this=0x7fffffffce50
looks invalid.What happens if you run this code instead:
void GLWidget::paintGL() { QPainter painter(this); painter.beginNativePainting(); tangramProcessNetworkQueue(); double timeNow = currentTime(); tangramUpdate(map, timeNow - lastTime); lastTime = timeNow; tangramRender(map); painter.endNativePainting(); update(); //< Do this externaly }
By the way why do you use a native painting block? It's somewhat unusual.