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. Bug in my code causing crash Qt Spectrogram
Forum Updated to NodeBB v4.3 + New Features

Bug in my code causing crash Qt Spectrogram

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 615 Views 1 Watching
  • 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.
  • Y Offline
    Y Offline
    Yippiyak
    wrote on last edited by
    #1

    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.

    J

    0_1531963852045_atomic_error.PNG

    0_1531963836694_Capture.PNG

    aha_1980A 1 Reply Last reply
    0
    • Y Yippiyak

      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.

      J

      0_1531963852045_atomic_error.PNG

      0_1531963836694_Capture.PNG

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Yippiyak

      ... and line 45 is which one?

      thanks

      Qt has to stay free or it will die.

      Y 1 Reply Last reply
      1
      • aha_1980A aha_1980

        @Yippiyak

        ... and line 45 is which one?

        thanks

        Y Offline
        Y Offline
        Yippiyak
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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