Results 1 to 2 of 2

Thread: concurrency issues with QwtData

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default concurrency issues with QwtData

    Hi all,

    I implemented my own QwtData which works with a ring buffer and is filled from a different thread than the plot.
    Because the Plotter stops the plot with a QMutex before setting rawData
    Qt Code:
    1. curveList[a]->setRawData(dataList[a].x(), dataList[a].y(), dataList[a].size());
    To copy to clipboard, switch view to plain text mode 
    everything worked fine.


    Qt Code:
    1. void ValuePlotData::append(qint64 xValue, qint64 yValue)
    2. {
    3. if(currentValuecount == arraySize)
    4. {
    5. long newArraySize = arraySize*2;
    6. double * d_x_new = new double[newArraySize];
    7. double * d_y_new = new double[newArraySize];
    8. for(int i=0;i<arraySize;i++)
    9. {
    10. d_x_new[i]=d_x[i];
    11. d_y_new[i]=d_y[i];
    12. }
    13. delete [] d_x;
    14. delete [] d_y;
    15. d_x = d_x_new;
    16. d_y = d_y_new;
    17. arraySize = newArraySize;
    18. }
    19. d_x[currentValuecount] = xValue;
    20. d_y[currentValuecount] = yValue;
    21. currentValuecount++;
    22. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. double ValuePlotData::x(size_t i) const
    2. {
    3. return d_x[offset+(int)i];
    4. }
    To copy to clipboard, switch view to plain text mode 

    Now I had to use a zoomer for the plot and problems started.

    Whenever I zoom in or out there is a chance of the program crashing with a "call to pure virtual method".
    After getting post mortem debugging ready I found out, that a replot was issued and it died as I believe on Calling .x() method

    I initialize the zoomer with AutoReplot(false) but still it seems to crash because of that.

    How do you take care of concurrency issues with your plot, because I don't think it is wise to fill from the gui thread for many new values.

    Thanks in advance, this has allready cost me several hours.

    sun

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

    Default Re: concurrency issues with QwtData

    Qwt doesn't take care of races at all. I remember a discussion ( almost 10 years ago ), whether QwtData should offer some sort of lock mechanisms, but in the end the decision was to leave this to the application code ( can't remember the arguments and if they are still valid today ).

    A possible solution (implemented in the oscilloscope example in SVN trunk ) is to add lock/unlock methods to your data object using them in your sampling thread and the paint operations ( YourPlot::replot() or YourCurve::draw() ).

    Uwe

Similar Threads

  1. 4.6.0 issues on OS X 10.6 with GL
    By treaves in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2009, 17:12
  2. Level of Details QwtData Technique?
    By baray98 in forum Qwt
    Replies: 1
    Last Post: 4th September 2009, 07:51
  3. QProcess issues
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2008, 14:15
  4. QTableWidget issues
    By Djony in forum Qt Programming
    Replies: 42
    Last Post: 19th December 2006, 23:27
  5. Parental issues
    By chaosgeorge in forum Qt Programming
    Replies: 4
    Last Post: 13th November 2006, 04:10

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.