QCustomPlot Discussion and Comments

OpenGL enabled on multiple QCustomPlots leads to SegfaultReturn to overview

I am just starting to use QCustomPlot and I added multiple QCustomPlot on the same layout with setOpenGl(true), this leads to a segfault, stack trace:

#1 0x00007ffff66638a6 in QOpenGLContext::makeCurrent(QSurface*) () from /usr/lib/libQt5Gui.so.5
#2 0x000000000042864f in QCPPaintBufferGlFbo::reallocateBuffer (this=0x7fffe1168d30) at qcustomplot.cc:938
938 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
#3 0x00000000004277a3 in QCPAbstractPaintBuffer::setSize (this=0x7fffe1168d30, size=...) at qcustomplot.cc:594
594 reallocateBuffer();
#4 0x0000000000455357 in QCustomPlot::setupPaintBuffers (this=0x7fffe9c8af80) at qcustomplot.cc:14822
14822 mPaintBuffers.at(i)->setSize(viewport().size()); // won't do anything if already correct size
#5 0x000000000045306a in QCustomPlot::replot (this=0x7fffe9c8af80, refreshPriority=QCustomPlot::rpQueuedRefresh) at qcustomplot.cc:14151
14151 setupPaintBuffers();
#6 0x0000000000453d44 in QCustomPlot::resizeEvent (this=0x7fffe9c8af80, event=0x7fffffffc800) at qcustomplot.cc:14478
14478 replot(rpQueuedRefresh); // queued refresh is important here, to prevent painting issues in some contexts (e.g. MDI subwindow)
#7 0x00007ffff6e0134e in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#8 0x00007ffff6db9e0c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#9 0x00007ffff6dc1581 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5

If I enable setOpenGl on only the first QCustomPlot it works fine.

I am using an update Arch Linux distro.

I'm having the exact same issue. Where you able to find a fix?

Not yet.. Left it for later to debug, will get around to debugging it when I have time

Same problem here. Thanks for letting me know if someone of you you has found a fix for this.

I'm aware of the issue, it has to do with some OpenGL drivers/graphics cards not being able to share frame buffer objects (at lest in the way Qt does it). QCP tries to solve most problems that come with multiple OpenGL surfaces by releasing/making current the respective FBOs after/before drawing. This works on some systems, but seemingly not on all of them.

Given the large spectrum of different OpenGL platforms I've come to the conclusion that the new OpenGL interface (QCustomPlot::setOpenGl) will stay experimental for some versions and mature during the QCP 2.x series. While many systems seem to work just fine out of the box, some show issues from performance lag to display glitches (e.g. with High DPI screens and older GL drivers).

In the meantime the only solution is to enable OpenGL only on one QCP in your application, if the platform shows to have problems with multiple GL surfaces in parallel.