Skip to content

GraphicsLayout: Always call processEvents after adding items#1167

Closed
2xB wants to merge 1 commit intopyqtgraph:developfrom
2xB:fix-1136
Closed

GraphicsLayout: Always call processEvents after adding items#1167
2xB wants to merge 1 commit intopyqtgraph:developfrom
2xB:fix-1136

Conversation

@2xB
Copy link
Copy Markdown
Contributor

@2xB 2xB commented Apr 11, 2020

Items added to a GraphicsLayout need a call to processEvents to receive their size information.
Needing to call processEvents is unintuitive, leading to multiple issues (see below).
This commit fixes that by always calling processEvents after adding items.

Fixes #8
Fixes #1136

Items added to a GraphicsLayout need a call to 'processEvents' to receive their size information.
Needing to call 'processEvents' is unintuitive, leading to multiple issues (see below).
This commit fixes that by always calling 'processEvents' after adding items.

Fixes pyqtgraph#8
Fixes pyqtgraph#1136
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Apr 12, 2020

oof...this might be a tough pill we have to swallow... going to ask @campagnola for input.

@campagnola
Copy link
Copy Markdown
Member

I agree with @j9ac9k -- adding processEvents is problematic because it introduces the possibility of other Qt events being handled while in the middle of addItem. That effectively changes the order in which user code gets executed, which can introduce weird and difficult to fix bugs. Sorry, I think we need a different solution to this problem. Perhaps better documentation / error reporting would be sufficient?

@campagnola campagnola closed this Apr 13, 2020
2xB added a commit to 2xB/pyqtgraph that referenced this pull request Apr 13, 2020
Items added to a `GraphicsLayout` only learn their size information
after the internal `QGraphicsGridLayout` recalculates the layout.
This is happening as a slot in the Qt event queue.
Not having updated geometry bounds directly after adding an item
leads to multiple issues when not executing the Qt event loop
in time (see below). This commit fixes that by always calling
`layout.activate()` after adding items, updating item sizes
directly.

This is a follow-up to PR pyqtgraph#1167, where introducing a direct call to
`processEvents` was suspected to be able to cause side effects.

Notifying @j9ac9k and @campagnola, as they were involved in pyqtgraph#1167.

Fixes pyqtgraph#8
Fixes pyqtgraph#1136
2xB added a commit to 2xB/pyqtgraph that referenced this pull request Apr 13, 2020
Items added to a `GraphicsLayout` only learn their size information
after the internal `QGraphicsGridLayout` recalculates the layout.
This is happening as a slot in the Qt event queue.
Not having updated geometry bounds directly after adding an item
leads to multiple issues when not executing the Qt event loop
in time (see below). This commit fixes that by always calling
`layout.activate()` after adding items, updating item sizes
directly.

This is a follow-up to PR pyqtgraph#1167, where introducing a direct call to
`processEvents` was suspected to be able to cause side effects.

Notifying @j9ac9k and @campagnola, as they were involved in pyqtgraph#1167.

Fixes pyqtgraph#8
Fixes pyqtgraph#1136
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.

an issue on ViewBox.mapToView Avoid export bug by calling processEvents() before export

3 participants