Hi,
I found a bug in QwtPlotPicker (either in the code or in the documentation, depending on how it is supposed to work):
When I create a plot picker I pass the canvas of a plot as its parent (according to documentation). However, when I delete the plot and hence its canvas, the plot picker is not deleted and does not stop working which leads to an access violation when the picker internally accesses the plot in the method QwtPlotPicker::invTransform.
If the plot picker is deleted in the plot's destructor manually, all works fine. Here is an example:
Qt Code:
{ public: { m_picker->setStateMachine(new QwtPickerTrackerMachine()); } ~MyPlot() { //delete m_picker; } private: QwtPlotPicker* m_picker; }; { Q_OBJECT public: { ui.setupUi(this); m_plot = new MyPlot(this); layout()->addWidget(m_plot); } protected: { if (event->key() == Qt::Key_D) { if (m_plot != nullptr) { delete m_plot; m_plot = nullptr; } } } private: Ui::TempPlotClass ui; MyPlot* m_plot; };To copy to clipboard, switch view to plain text mode
Press the "d" key while moving the mouse over the plot. If the line in ~MyPlot is commented out, the application will crash.
Bookmarks