Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't call draw() twice when Qt canvas first appears. #9103

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
merged 1 commit into from
Aug 28, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 26, 2017

Right now the resizeEvent triggered from within the paintEvent will
itself trigger a second paintEvent. Adding a print to draw() shows that
this patch ensures that draw() only gets called once the first time the
canvas appears.

See http://doc.qt.io/qt-5/qwidget.html#resizeEvent http://doc.qt.io/qt-4.8/qwidget.html#resizeEvent for relevant docs.

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

Right now the resizeEvent triggered from within the paintEvent will
itself trigger a second paintEvent.  Adding a print to draw() shows that
this patch ensures that draw() only gets called once the first time the
canvas appears.
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 27, 2017
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 27, 2017
@WeatherGod
Copy link
Member

This seems reasonable, but I am not sure I understand why some code was moved into backend_qt5 and other code was simply moved around within backend_qt5agg?

@anntzer
Copy link
Contributor Author

anntzer commented Aug 28, 2017

Whatever is independent of Agg (and would be used just as much by #8771) was moved out of backend_qt5agg into backend_qt5.

@WeatherGod
Copy link
Member

Ok, that makes some sense, but with the way the code is right now, isn't the backend_qt5 completely broken now? Does _dpi_ratio_prev ever get set within the pure qt5 backend?

@anntzer
Copy link
Contributor Author

anntzer commented Aug 28, 2017

It is up to whoever else wants to implement a qt5 backend to also update the dpi in their own reimplementation of the paintEvent handler (e.g. https://github.com/matplotlib/matplotlib/pull/8771/files#diff-24903670c280dbda97ed82b992060879).

The pure qt5 backend cannot be used without a renderer. Its whole purpose is to be inherited by classes that will actually be coupled to a specific renderer.

@dopplershift dopplershift merged commit d0eeddb into matplotlib:master Aug 28, 2017
@anntzer anntzer deleted the no-double-draw branch August 28, 2017 19:38
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