Skip to content

Commit 7d7014d

Browse files
authored
Fix: legend now showing up when enabled later
In our code base we had code which does: 1. Create a plot 2. Attach a curve 3. Enable legend This worked in Qwt 5, but with PythonQwt the legend was not showing up. Switching the order of 2 and 3 caused the legend to then appear. Debugging I found out blocking signals around `updateLegend` inside `insertLegend` was the culprit. The original source code [does not block signals](https://sourceforge.net/p/qwt/code/HEAD/tree/trunk/qwt/src/qwt_plot.cpp#l943), but calls [`qwtEnableLegendItems`](https://sourceforge.net/p/qwt/code/HEAD/tree/trunk/qwt/src/qwt_plot.cpp#l27), which only disconnects/connects `updateLegendItems`. Doing the same here fixed the issue: now enabling the legend in a plot which already has curves causes the legend to appear correctly.
1 parent 35c9fc2 commit 7d7014d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

qwt/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,9 @@ def insertLegend(self, legend, pos=None, ratio=-1):
15601560
if self.__data.legend.parent() is not self:
15611561
self.__data.legend.setParent(self)
15621562

1563-
self.blockSignals(True)
1563+
self.legendDataChanged.disconnect(self.updateLegendItems)
15641564
self.updateLegend()
1565-
self.blockSignals(False)
1565+
self.legendDataChanged.connect(self.updateLegendItems)
15661566

15671567
lpos = self.__data.layout.legendPosition()
15681568

0 commit comments

Comments
 (0)