Skip to content
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

Fix errors from incorrect QImage memory management. #546

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

corranwebster
Copy link
Contributor

This should stop the sporadic test failures caused by referencing memory which has been freed and used by something else. The fix is to attach the numpy array with the allocated memory to the QImage, so that the lifetime of the array is at least as long as that of the QImage.

Fixes #517

This should stop the sporadic test failures caused by referencing memory
which has been freed and used by something else.  The fix is to attach the
numpy array with the allocated memory to the QImage, so that the lifetime
of the array is at least as long as that of the QImage.
Copy link
Contributor

@ievacerny ievacerny left a comment

Choose a reason for hiding this comment

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

One way I found to consistently reproduce the error is to save the qimage to file multiple times (at least 3) in the failing test. With this I was able to get the test to fail even when running on its own. It might not be the most reliable test but it might be good enough to test for regression.

Anyways, I can confirm that the fix works and my locally modified test no longer fails.

@mdickinson mdickinson closed this Jun 22, 2020
@mdickinson mdickinson reopened this Jun 22, 2020
@mdickinson
Copy link
Member

(Closed and re-opened to retrigger CI; on the previous CI run, the Travis CI job completed successfully but didn't report back to GitHub.)

@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2020

Codecov Report

Merging #546 into master will increase coverage by 0.61%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #546      +/-   ##
==========================================
+ Coverage   36.99%   37.60%   +0.61%     
==========================================
  Files         470      470              
  Lines       26027    26364     +337     
  Branches     3961     4029      +68     
==========================================
+ Hits         9629     9915     +286     
- Misses      15977    16022      +45     
- Partials      421      427       +6     
Impacted Files Coverage Δ
pyface/ui/qt4/util/image_helpers.py 97.14% <100.00%> (+0.08%) ⬆️
pyface/ui/qt4/dialog.py 94.78% <0.00%> (+0.84%) ⬆️
pyface/ui/qt4/action/action_item.py 43.88% <0.00%> (+2.56%) ⬆️
pyface/ui/qt4/action/tool_bar_manager.py 84.15% <0.00%> (+3.80%) ⬆️
pyface/ui/qt4/action/menu_manager.py 67.78% <0.00%> (+4.99%) ⬆️
pyface/ui/qt4/about_dialog.py 89.28% <0.00%> (+7.70%) ⬆️
pyface/ui/qt4/progress_dialog.py 94.47% <0.00%> (+8.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08ba6c2...68880e5. Read the comment docs.

@corranwebster corranwebster merged commit d619063 into master Jun 22, 2020
@corranwebster corranwebster deleted the fix/image-helpers-test-failures branch June 22, 2020 13:56
@kitchoi kitchoi added this to the Release 7.0.1 milestone Jun 30, 2020
kitchoi pushed a commit that referenced this pull request Jul 8, 2020
This should stop the sporadic test failures caused by referencing memory
which has been freed and used by something else.  The fix is to attach the
numpy array with the allocated memory to the QImage, so that the lifetime
of the array is at least as long as that of the QImage.
kitchoi added a commit that referenced this pull request Jul 8, 2020
* Fix errors from incorrect QImage memory management. (#546)

This should stop the sporadic test failures caused by referencing memory
which has been freed and used by something else.  The fix is to attach the
numpy array with the allocated memory to the QImage, so that the lifetime
of the array is at least as long as that of the QImage.

* Fix dock pane layout (#545)

* Provide sizeHint to QWidget

* REF : Restore qt4 conditional branch

	modified:   pyface/ui/qt4/tasks/main_window_layout.py

* TST: Test Qt dock widget has the correct size (#552)

Co-authored-by: Sai Rahul Poruri <rporuri@enthought.com>
Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* Update Changelog for 7.0.1

* Remove master only setting on Travis and Appveyor which prevent bug fix release PR from building

* Update .travis.yml for Qt (#529)

* Update .travis.yml to include libglu1-mesa-dev for Qt

* Restore libxkbcommon-x11 and move other dependencies up

* Fix package name for libsdl

* Add a debug flag

* Add libxcb-iccm4

* Continue the same exercise for pyside2, add libxcb-image

* Giving up - let's use the same packages

* Add libxml2 for osx image

* Use brew manually
See https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/28

* Try a newer osx image

* Add a comment

* Is libdbus still needed?

* Remove debugging flag - it is noisy and is embedded in between tests

* Update install command for installing wx to match master (this is equivalent to a merge of a couple of PRs

Co-authored-by: Corran Webster <cwebster@enthought.com>
Co-authored-by: Pedro Rivotti <44579232+pedrorivotti@users.noreply.github.com>
Co-authored-by: Sai Rahul Poruri <rporuri@enthought.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sporadic test_array_to_qimage_rgb failure using pyside2
5 participants