Skip to content

Emit sigRegionChanged only once for LinearRegionItem#3291

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jdranczewski:LinearRegionItem
Mar 31, 2025
Merged

Emit sigRegionChanged only once for LinearRegionItem#3291
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jdranczewski:LinearRegionItem

Conversation

@jdranczewski
Copy link
Copy Markdown
Contributor

LinearRegionItem currently fires sigRegionChanged three times when setRegion is used. This seems to be due to the blockLineSignal flag being cleared too early.

I propose to move the flag lower down to fix this - in my testing this results in the signal being fired once instead of thrice.

Minimal code that reproduces this issue in pyqtgraph-0.13.7:

import pyqtgraph as pg
w = pg.PlotWidget()
w.show()
w.plotItem.addItem(region := pg.LinearRegionItem())
region.sigRegionChanged.connect(lambda: print("fired"))
region.setRegion((2, 3))

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Mar 31, 2025

Ha, I completely forgot about this, this was one of the first bugs I recognized in the library when I first started using it... Never got around to fixing it (or opening an issue it would seem).

Thanks for the PR @jdranczewski

@j9ac9k j9ac9k merged commit 8440c2c into pyqtgraph:master Mar 31, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants