QCustomPlot Discussion and Comments

Application Not Responsive After Extended PeriodsReturn to overview

Hi all,

I'm having an issue with an application I am writing, where it becomes unresponsive after ~12 hours. The application gathers data from a sensor every ~1-2 seconds, and plots the the data for the user to see.

The sensor puts out a LOT of different data, so I have (currently) individual 13 series which I spread out over 8 different plots.

The basic flow of my application is this: When the user presses "start", create a new thread with a while(run) loop attached to it. This loop is responsible for the collection of data. When the loop is complete (emits loopDone signal), I use ui->plot_XXX->graph(X)->addData(newX, newY), followed by rescaleAxes(), and finally replot().

This method works great and has good UI responsiveness initially, but when I leave it running for a long time, overnight for example, the UI becomes unresponsive. Interestingly, the thread is still running because I can see the sensor's LED blinking which indicates activity.

Any thoughts?

Thank you!

as you add data, the amount of data that rescaleAxes() has to go through increases dramatically. you can make a few optimizations that i've mentioned before, such as changing how it calculates the bounds in the xaxis and y axis directions. if you are doing a real time application, obviously you dont need to recalculate the x bounds by going through the data because obviously the first data point is your left bound and your last data point is your right bound.

as for y values. i implemented a function where when i add data, it expands the bounds of my y axis and just stores the range... then when the rescaleAxes is asking for the data range, i just return the range.

this will basically mean that your rescaleAxes calculation will now take no time. drawing still takes a while with a lot of data points, but there is already an optimization page somewhere on the site.