Hi all
I am using QCustomPlot from dev-2.1.0 branch (0482767c) to build charts and save them to PNG without showing them on screen. Ok, admittedly a corner case.
Running on Linux 64bit, gcc 8.3.0, Qt 5.11.3 OpenGL enabled I get segfaults from time to time. Interestingly enough if I DISABLE OpenGL (remove the QCUSTOMPLOT_USE_OPENGL define) the segfaults go away.
Segfaults always appear either in QCustomPlot destructor or QApplication destructor, but I'm unable to pinpoint the cause, even with valgrind help.

Any help would be much appreciated.

The following test program segfaults 20% of the times

#include <QApplication>
#include <QTimer>

#include <core.h>
#include <plottables/plottable-graph.h>

void fn1()
{
    QCustomPlot* customPlot {new QCustomPlot()};

    auto graph = customPlot->addGraph();
    graph->setPen(QPen(Qt::blue)); // line color blue for first graph
    graph->setBrush(QBrush(QColor(0, 0, 255, 20))); // first graph will be filled with translucent blue
    QVector<double> x(16);
    for (int i=0; i<16; i++)
        x[i] = i;

    graph->setData(x, x);
    graph->rescaleAxes();
    customPlot->xAxis2->setVisible(true);
    customPlot->xAxis2->setTickLabels(false);
    customPlot->yAxis2->setVisible(true);
    customPlot->yAxis2->setTickLabels(false);
    customPlot->savePng("chart.png");

    delete customPlot;
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTimer::singleShot(0, fn1);

    QTimer::singleShot(500, &a, SLOT(quit()));
    auto retval {a.exec()};

    return retval;
}