Skip to content

Fix nullptr disconnect warning when destroying an OpenGL enabled chart#8

Closed
pylessard wants to merge 1 commit intoqt:devfrom
pylessard:fix-nullptr-disconnect-with-opengl
Closed

Fix nullptr disconnect warning when destroying an OpenGL enabled chart#8
pylessard wants to merge 1 commit intoqt:devfrom
pylessard:fix-nullptr-disconnect-with-opengl

Conversation

@pylessard
Copy link

@pylessard pylessard commented Mar 7, 2026

When destroying an OpenGL enabled chart, I encounter a reproducible warning :
qt.core.qobject.connect: QObject::disconnect: Unexpected nullptr parameter

After review, I found that the GLWidget::cleanup() can be called twice if the context is deleted before the GLWidget. The warning happens because the cleanup function is not idempotent and the second time tries to disconnect a nullptr.
This PR aim to make the cleanup function idempotent.

The first call comes from the signal QOpenGLContext::aboutToBeDestroyed and the second call comes from the GLWidget destructor.

When using the public API of QtCharts in Python, I do not have control over the chart GLContext object lifecycle (as far as I know). I don't have a viable workaround other than fixing this root cause.

@cla-assistant
Copy link

cla-assistant bot commented Mar 7, 2026

CLA assistant check
All committers have signed the CLA.

@pylessard
Copy link
Author

pylessard commented Mar 7, 2026

I added a Minimal Reproducing Example here using PySide6. It's attached to this comment

Starting the program will display an OpenGL enabled chart. Hitting the Delete key will destroy it.

Before "Delete" :
image

After "Delete"
image

chart-nullptr-mre.py

@pylessard
Copy link
Author

@pylessard pylessard closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant