Important: Please read the Qt Code of Conduct -

Bug in my code causing crash Qt Spectrogram

  • Here is the code I believe is suspect as there is a direct reference to Line 45 in my showpeak function in the call stack.

    void ShowPeak::updatePeak()
    m_peak = QPointF(0, -100000);

    QXYSeries* series = static_cast<QXYSeries*>(m_chart->series()[0]);
    QValueAxis* axisX = static_cast<QValueAxis*>(m_chart->axisX(series));
    for (const QPointF& p : series->pointsVector())
        if (p.y() > m_peak.y()
            && p.x() >= axisX->min()
            && p.x() <= axisX->max())
            m_peak = p;


    I am using multithreading, but I am not sure what exactly is causing my project to fail. The error code is:

    Exception thrown: read access violation.
    _Tgt was 0x2990070.

    Many thanks to anyone who can provide any insight.




  • Lifetime Qt Champion


    ... and line 45 is which one?


  • @aha_1980
    for (const QPointF& p : series->pointsVector())

  • Lifetime Qt Champion


    Are you sure that this pointer is valid ?
    Also, you should rather use dynamic_cast (or qobject_cast if it’s for a QObject based class) and check the returned value against null_ptr.

Log in to reply