Cannot remove the legend from a visible plot window

insertLegend(None) does not remove the legend if show() is already been called.

from PyQt5.QtWidgets import QApplication
from qwt import QwtPlot, QwtPlotCurve, QwtLegend

app = QApplication([])

plot = QwtPlot()
legend = QwtLegend()
plot.insertLegend(legend, plot.TopLegend)

x_values = list(range(0, 10))
curve = QwtPlotCurve("Curve")
curve.setData(x_values, x_values)
curve.attach(plot)

plot.updateAxes()
plot.show()
# Remove the legend
plot.insertLegend(None)

app.exec()

Calling legend.setParent(None) before insertLegend(None) fix the issue and the legend is removed accordingly. If show is called before inserLegend(None), it also works correctly.

PythonQwt: 0.14.4
PyQt: 5.15.11