Repository navigation
Fix qt gc segfault - #474
Merged
jenshnielsen merged 2 commits intoOct 6, 2026
Merged
Conversation
jenshnielsen
force-pushed
the
fix-qt-gc-segfault
branch
from
October 5, 2026 08:19
a8b104a to
7ba9598
Compare
jenshnielsen
marked this pull request as ready for review
October 6, 2026 06:54
astafan8
approved these changes
Oct 6, 2026
jenshnielsen
enabled auto-merge
October 6, 2026 08:09
Flowcharts, nodes and their pyqtgraph/Qt objects form reference cycles, so discarded ones are only freed by Python's cyclic garbage collector. When an allocation-triggered collection fires while Qt is constructing graphics items for another flowchart, destroying the old Qt object trees can segfault the process. This crashed the test suite (mid-run on Windows, at interpreter shutdown on Linux CI with Python 3.14) and can also hit the apps, e.g. when inspectr replaces a plot window's flowchart. - Add plottr.enableEventLoopGarbageCollection(), which uses pyqtgraph's GarbageCollector to collect only from the Qt event loop, plus once on aboutToQuit, and enable it in the standalone apps (autoplot, inspectr, monitr, apprunner). Library use is unchanged since this affects the whole interpreter; the README documents how to opt in. - In the test suite, disable automatic collection during each test and collect explicitly afterwards.
dataLoaded is emitted before the queued onThreadComplete() slot updates the flowchart output, so wait for the new data as the first half of the test already does.
jenshnielsen
force-pushed
the
fix-qt-gc-segfault
branch
from
October 6, 2026 08:30
7ba9598 to
79378e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use garbage collector from pyqtgraph in qt apps. This should resolve crashes due to the std garbage collector not working well with the qt event loop