i plot a very large number of QCPItemLine (arrows) on a chart. the data for arrow->start and arrow->end are in a std::vector. This vector is iterated in a loop and the item objects are created there. With replot() the created items should be displayed.
After that I want to free the memory and empty the vector with .clear() and .shrink_to_fit().
// first the loop that create all the QCPItemLine Objects. after that:
The program crashes this way!
I think the reason is probably because replot() doesn't block until the completion of drawing the items (could work asyncron). The vector will be deleted before replot() is complete and there is no more data at the location for drawing the items.
How can you make replot() block until the objects are completely drawn on the chart?
I tried the variants like "QCustomPlot::rpImmediateRefresh" etc but even then it crashes.
if i use std::this_thread::sleep_for(std::chrono::milliseconds(x)) to give replot more time, then it also blocks drawing in the chart.
Does anyone have a solution how I can delete the vector after replot() but not before the replot() has finished drawing in GUI? Is there a possibility to block until the chart is completely drawn (before deleting the vector)?