FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cooperative __init__ for Qt4 canvas. by anntzer · Pull Request #9052 · matplotlib/matplotlib · GitHub

Repository navigation

Cooperative __init__ for Qt4 canvas. - #9052

Merged
tacaswell merged 1 commit into
matplotlib:masterfrom
anntzer:cooperative-pyqt4-init
Aug 22, 2017
Merged

tacaswell merged 1 commit into
matplotlib:masterfrom
anntzer:cooperative-pyqt4-init

Conversation

anntzer commented Aug 17, 2017

Copy link
Copy Markdown
Contributor

Alternate for #9048 (basically pulling out the relevant parts of #8771, but using a local monkey-patch approach.
I personally find this approach clearer in intent ("PyQt4 does not support multiple inheritance so let's just locally patch it so that it does") than #9048.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

tacaswell added this to the 2.1 (next point release) milestone Aug 17, 2017
tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 17, 2017

tacaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

One paranoid comment, but overall seems reasonable.

Comment thread lib/matplotlib/backends/backend_qt5.py Outdated

@functools.wraps(__init__)
def wrapper(self, **kwargs):
QtWidgets.QWidget.__init__ = cooperative_qwidget_init

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This needs to be in a try..finally block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The initial monkey-patch should also be in the try block... ctrl-c can happen anywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Wow, I'm a bit ashamed I never thought about this point :-)

Copy link
Copy Markdown
Member

I lean towards this as the better solution (I started writing a comment about how I was even between them and in the process convinced my self to prefer this one).

This has the advantage of being cleaner and more localized but hard-codes the non-cooperative modules in. However, odds of another binding showing up are low and doing the sub-classing and replacing __init__ while waiting for changes to be merged upstream isn't that bad.

#9048 uses 'simpler' python, but it makes the class zoo one class bigger and has to use two differently named 'magic' cut-out function, and is spread across a couple of files. It makes the unlikely extension case easier (once you understand the code), but harder to understand to begin with.

tacaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Be more paranoid in re-setting the __init__

anntzer force-pushed the cooperative-pyqt4-init branch from 5ee6e51 to 7b09c20 Compare August 17, 2017 23:37

anntzer commented Aug 17, 2017

Copy link
Copy Markdown
Contributor Author

try... finally added.
Honestly, I think anyone coming up with a new qt binding that does not support cooperative inheritance does not deserve being supported by matplotlib :-) (you can make the mistake once, but you should learn from previous mistakes!)

anntzer force-pushed the cooperative-pyqt4-init branch from 7b09c20 to f007419 Compare August 18, 2017 06:46

efiring commented Aug 21, 2017

Copy link
Copy Markdown
Member

Appveyor failure is just a hang at the start of the conda-build on 3.6.

tacaswell merged commit c0bceb1 into matplotlib:master Aug 22, 2017
anntzer deleted the cooperative-pyqt4-init branch August 22, 2017 16:18
anntzer mentioned this pull request Aug 26, 2017
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

Labels

GUI: Qt Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL