Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QChart Crash while adding dynamically multiple QLineSeries



  • Hello Team,

    I am using QChart for plotting some data on QChartView, Facing crash while close the Application.
    1)It does not crash while add only one QLineSeries, It works fine.
    2)It happens, when I add the multiple QLineSeries dynamically, Please give any suggestion if i am doing wrong somewhere below in code.

    if((signalValues.size() > 0) && (m_chart->series().count() < 10) && (checkState))
    {
        if(!m_mapSeries.contains(signalName))
        {
            SignalTracer *signalTracer = new SignalTracer(m_chart);
            m_mapSignalTracerItem.insert(signalName, signalTracer);
            m_signalName = signalName;
            QLineSeries *signalSeries = new QLineSeries(m_chart); // I tried through QPointer also but it does not work
            signalSeries->setName(signalName);
    
            QVector<qreal> yAxisRange = signalValues;
            qSort(yAxisRange.begin(),yAxisRange.end());
            m_axisY->setRange(yAxisRange.first(),yAxisRange.last());
            show();
            m_timeStampValues.clear();
            m_timeStampValues = timeStampValues.toVector();
    
            for(qulonglong timeStamp = 0; timeStamp < timeStampValues.size(); timeStamp++)
            {
                signalSeries->append(timeStampValues.at(timeStamp), signalValues.at(timeStamp));
            }
    
            m_chart->addSeries(signalSeries);
            m_mapSeries.insert(signalName, signalSeries);
            m_mapSignalValues.insert(signalName, signalValues);
    
            connect(signalSeries, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool)));
            this->setMouseTracking(true);
        }
    }


  • @Shivraj-Raghuwanshi
    I don't know what the issue is in your code. But if I were faced with "crash while close the Application", I would start by hooking onto the close and explicitly deleting all the objects/series/etc. I had created. Hopefully you will then see where the issue lies. You could also try running inside debugger and see if the crash traceback gives you a clue.



  • ![alt text](QChartCrash.PNG image url)

    Hello JonB,

    Please find the attached png which i got the traceback but I did not get the any clue from this.

    I am deleting all the objects/series in destructor while close the Application before unload the plugin

    RadarOSZIChartView::~RadarOSZIChartView()
    {
    m_startLineItem = nullptr;
    m_endLineItem = nullptr;
    m_currentLineItem = nullptr;
    for(auto series : m_pChart->series())
    {
    qInfo()<<"clearing series::"<< series->name();
    m_pChart->removeSeries(series);
    delete series;
    series = nullptr;
    }

    m_pChart->removeAxis(m_axisTimeStamps);
    m_pChart->removeAxis(m_axis);
    
    delete m_axisTimeStamps;
    m_axisTimeStamps = nullptr;
    
    delete m_axis;
    m_axis = nullptr;
    
    delete m_pChart;
    m_pChart = nullptr;
    

    }



  • @Shivraj-Raghuwanshi
    Well, the traceback is full of references to QUrlQuery::setQueryItems(), so although your code shows no reference to that I presume elsewhere in your code you have something about that and it is where the issue lies? The issue has nothing to do with your chart?



  • @JonB

    My doubt is here- QLineSeries *signalSeries = new QLineSeries(m_chart); // This I create every time when i send the data from the TreeView DockWidget on checkbox clicked.

    If I do not use the QChart or do not send the data to plot, It does not crash.

    Application crash on exit when a QChart is created inside a DLL- I would like to know about this issue if you know something, My issue could be related to this also as I used this QChart in plugin but I am unloading the plugin before closing and deleting series and pointers in destructor.

    Please look into this- https://bugreports.qt.io/browse/QTBUG-66096



  • @Shivraj-Raghuwanshi
    I do not see anything in that bug which was not resolved or seems to bear any relationship to your situation.

    Do you have QUrlQueryanywhere in your code, or the code you call, by doing a comprehensive search for it, yes or no?



  • @JonB

    No,



  • @JonB

    Currently I am using Qt 5.7.0, Windows OS.
    It works fine, If I run this in Qt 5.13.1


Log in to reply