Results 1 to 7 of 7

Thread: Crashing QwtPlot

  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Crashing QwtPlot

    Hi Everyone,

    I am working on qwtplot, and its getting crash, as I'm trying to overload with data.
    I have read on this link http://www.qtforum.de/viewtopic.php?t=16041
    And come to the conclusion that I should use setRawSamples() rather than using setSamples().

    So previously I'm doing this,
    Qt Code:
    1. QVector<QPointF> m_points;
    2. //Adding some data to m_points
    3. m_points.push_back(QPointF(xValue, yValue));
    4. setSamples(m_points);
    To copy to clipboard, switch view to plain text mode 

    And now I'm trying with this below, but getting some error
    Qt Code:
    1. QVector<QPointF> m_points;
    2. //Adding some data to m_points
    3. m_points.push_back(QPointF(xValue, yValue));
    4. setRawSamples(m_points.at(0).x(), m_points.at(0).y(), sizeof(m_points));
    To copy to clipboard, switch view to plain text mode 

    Error:
    error: C2664: 'void QwtPlotCurve::setRawSamples(const double *,const double *,int)': cannot convert argument 1 from 'qreal' to 'const double *'
    In the above code I tried with casting but doesn't working.

    First of all I want to try this and want to check does is this the problem that crashing my application.
    If someone think, may be their is other problem then please mentioned that also.

    Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Crashing QwtPlot

    setRawSamples can avoid creating an extra copy of the data, but then you have to take care of the lifetime of your buffers.

    So the posted code for the second implementation is totally wrong:

    - it does not even compile ( passing doubles, where double* is expected )
    - the vector is on the stack ( = not caring of the lifetime )
    - the vector stores its values [x][y][x][y].. so there are no [x][x].. [y][y].. arrays inside

    Also note, that Qt containers do copy on write. So using setSamples already avoids copying, what makes the second implementation pointless.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    npatil15 (17th February 2019)

  4. #3
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crashing QwtPlot

    You right, the second implementation is not even compile and not even written right. The thing is that I'm unable to right it proper way, that's the other thing.
    And I came to this conclusion because, the line setRawSamples() is working fine if the data is not too fast, but if I given bulk or fast data its crashing at this point.
    Qt Code:
    1. void Input::plottingData(QVariant data)
    2. {
    3. if (data.userType() == QMetaType::QPointF)
    4. {
    5. m_points.push_back(data.toPointF());
    6. }
    7. if (data.userType() == QMetaType::Double)
    8. {
    9. double yValue = data.toDouble();
    10.  
    11. cframe::TimeStamp time = Module::createTimestamp();
    12. qint64 nanoElapsed = time.nSecsElapsed();
    13. double xValue = nanoElapsed/(double)1000000000;
    14. m_points.push_back(QPointF(xValue, yValue));
    15. }
    16. if (data.userType() == qMetaTypeId<QVector<QPointF>>())
    17. {
    18. QVector<QPointF> points = data.value<QVector<QPointF>>();
    19. m_points.append(points);
    20. }
    21.  
    22. m_curve.setSamples(m_points);
    23. }
    To copy to clipboard, switch view to plain text mode 

    Can you please check this code above and clarify does the problem is in the coding somewhere ?

    Thanks

  5. #4
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crashing QwtPlot

    Their is typo mistake,
    Quote Originally Posted by npatil15 View Post
    And I came to this conclusion because, the line setRawSamples() is working fine if the data is not too fast, but if I given bulk or fast data its crashing at this point.
    In the above statement, its setSamples() not setRawSamples()

  6. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Crashing QwtPlot

    The code is o.k.

  7. The following user says thank you to Uwe for this useful post:

    npatil15 (18th February 2019)

  8. #6
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crashing QwtPlot

    Okay, thanks.
    The I think the crashing issue is not here then,
    Still I need to debug my rest of code, why my plot is crashing during fast and bulk amount of data.

    Is their anything you can suggest to look over ?

  9. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Crashing QwtPlot

    Ask your debugger, use the sanitizer ...

  10. The following user says thank you to Uwe for this useful post:

    npatil15 (18th February 2019)

Similar Threads

  1. Qwt app crashing
    By K4ELO in forum Qwt
    Replies: 0
    Last Post: 25th March 2013, 13:57
  2. Replies: 9
    Last Post: 25th October 2012, 20:55
  3. Crashing without debug mode- No crashing with gdb debugger
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2011, 12:27
  4. Crashing TreeView
    By momesana in forum General Programming
    Replies: 1
    Last Post: 2nd May 2010, 10:09
  5. Replies: 6
    Last Post: 14th May 2009, 13:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.