Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QChart Crash while adding dynamically multiple QLineSeries
Forum Updated to NodeBB v4.3 + New Features

QChart Crash while adding dynamically multiple QLineSeries

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 869 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shivraj Raghuwanshi
    wrote on 16 Dec 2019, 08:37 last edited by
    #1

    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);
        }
    }
    
    J 1 Reply Last reply 16 Dec 2019, 09:09
    0
    • S Shivraj Raghuwanshi
      16 Dec 2019, 08:37

      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);
          }
      }
      
      J Offline
      J Offline
      JonB
      wrote on 16 Dec 2019, 09:09 last edited by JonB
      #2

      @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.

      S 1 Reply Last reply 16 Dec 2019, 09:31
      0
      • J JonB
        16 Dec 2019, 09:09

        @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.

        S Offline
        S Offline
        Shivraj Raghuwanshi
        wrote on 16 Dec 2019, 09:31 last edited by
        #3

        ![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;
        

        }

        J 1 Reply Last reply 16 Dec 2019, 09:49
        0
        • S Shivraj Raghuwanshi
          16 Dec 2019, 09:31

          ![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;
          

          }

          J Offline
          J Offline
          JonB
          wrote on 16 Dec 2019, 09:49 last edited by
          #4

          @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?

          S 1 Reply Last reply 16 Dec 2019, 11:03
          0
          • J JonB
            16 Dec 2019, 09:49

            @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?

            S Offline
            S Offline
            Shivraj Raghuwanshi
            wrote on 16 Dec 2019, 11:03 last edited by
            #5

            @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

            J 1 Reply Last reply 16 Dec 2019, 11:30
            0
            • S Shivraj Raghuwanshi
              16 Dec 2019, 11:03

              @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

              J Offline
              J Offline
              JonB
              wrote on 16 Dec 2019, 11:30 last edited by JonB
              #6

              @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?

              S 2 Replies Last reply 16 Dec 2019, 12:43
              0
              • J JonB
                16 Dec 2019, 11:30

                @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?

                S Offline
                S Offline
                Shivraj Raghuwanshi
                wrote on 16 Dec 2019, 12:43 last edited by
                #7

                @JonB

                No,

                1 Reply Last reply
                0
                • J JonB
                  16 Dec 2019, 11:30

                  @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?

                  S Offline
                  S Offline
                  Shivraj Raghuwanshi
                  wrote on 16 Dec 2019, 13:14 last edited by
                  #8

                  @JonB

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

                  1 Reply Last reply
                  0

                  1/8

                  16 Dec 2019, 08:37

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved