Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: be more cautious about checking widget size #30484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ksunden merged 3 commits into matplotlib:main from tacaswell:fix/qt_cleanup
Aug 29, 2025

Conversation

Copy link
Member

@tacaswell tacaswell commented Aug 29, 2025

This can fail if the c++ side of the object has already been cleaned up but the Python side is still lingering (due to refs in callbacks).

closes #29618

I do not think it is worth constructing a test to generate this case, but in the case where I saw it in the wild this fixed the tests locally for me.

PR checklist

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have an _isdeleted; should we be using that?

if self.height() <= 0 or self.width() <= 0:
return
except RuntimeError:
# This can happen if the c++ object is already cleaned up
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check the error message to ensure we’re not swallowing other potential RuntimeErrors?

Also, are we sure this is the only place that may access the C++ object?

Copy link
Member Author

We seem to have an _isdeleted; should we be using that?

Yes and than also handles Tim's comment.

This can fail if the c++ side of the object has already been cleaned up
but the Python side is still lingering (due to refs in callbacks).
closes matplotlib#29618 
Copy link
Member Author

I confirmed this also fixes the reproduce I found.

Copy link
Member

ksunden commented Aug 29, 2025
edited
Loading

Test failures appear to be related to a new release of coverage:

https://pypi.org/project/coverage/#history

https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst#version-7106--2025年08月29日

EDIT: Was not coverage, was pytest-rerunfailures

@ksunden ksunden merged commit a7e81ef into matplotlib:main Aug 29, 2025
48 of 50 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Aug 29, 2025
@tacaswell tacaswell deleted the fix/qt_cleanup branch August 29, 2025 20:55
ksunden added a commit that referenced this pull request Aug 29, 2025
...484-on-v3.10.x
Backport PR #30484 on branch v3.10.x (FIX: be more cautious about checking widget size)
@ksunden ksunden mentioned this pull request Aug 30, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@QuLogic QuLogic QuLogic left review comments

@timhoffm timhoffm timhoffm left review comments

@ksunden ksunden ksunden approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
v3.10.6
Development

Successfully merging this pull request may close these issues.

[Bug]: FigureCanvasQT is seemingly prematurely freed under certain conditions

AltStyle によって変換されたページ (->オリジナル) /