I suspect that there is a double deletion of the same object (QwtLegend) occurs in your code:
Due to using auto_ptr in the
Plot
class,I suspect that Qwt also deletes the legend pointer that use assigned to the plot with
this->insertLegend(legend.get(), QwtPlot::BottomLegend);
call. Just looking into QwtPlot sources, makes this obvious:QwtPlot::~QwtPlot() { [..] delete d_data; // <- deletes the private data }
And the private data uses
QPointer
to delete referenced legend:class QwtPlot::PrivateData { public: [..] QPointer<QwtAbstractLegend> legend; // <-- will delete the legend };
So, I conclude that you do not need to explicitly delete your legend
, bur rely on the fact that QwtPlot takes the ownership on it.