Skip to content
New issue

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

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

Already on GitHub? # to your account

QImage: Add conversion from image::RgbaImage #1157

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LeonMatthesKDAB
Copy link
Collaborator

Because the image crate changes versions somewhat frequently, the
features in CXX-Qt are added with explicit image crate versions.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (cdc5ef9) to head (d72f971).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1157   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           71        71           
  Lines        11967     11967           
=========================================
  Hits         11967     11967           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LeonMatthesKDAB LeonMatthesKDAB force-pushed the qimage-constructors branch 4 times, most recently from 3bc2f5e to 15c2008 Compare January 17, 2025 10:43
@LeonMatthesKDAB LeonMatthesKDAB added the backport-candidate Change which could be backported to the stable series label Jan 17, 2025
@ahayzen-kdab
Copy link
Collaborator

Looks good, small questions and conflicts

@ahayzen-kdab
Copy link
Collaborator

Needs some conflicts resolving otherwise looks good i think.

format: QImageFormat,
) -> Self {
extern "C" fn delete_boxed_vec(boxed_vec: *mut ffi::c_void) {
drop(Box::new(boxed_vec as *mut Vec<u8>));
Copy link
Member

Choose a reason for hiding this comment

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

this looks bogus to me, can you explain it please? isn't Box::new() like a std::make_unique, meaning it does a new memory allocation? Or is this a misnomer and it actually adopts the ptr that gets passed in, so more like std::unique_ptr<T>(...)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good catch, thank you!

It needs to be Box::from_raw. Should be fixed now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious that valgrind didn't spot this, or are only the Qt unit tests not the cargo test run under valgrind ? Maybe this should be added to the qt_types_standalone or we should run the cargo test (even just for cxx-qt-lib) under valgrind ? 🤔

Copy link
Collaborator Author

@LeonMatthesKDAB LeonMatthesKDAB Jan 29, 2025

Choose a reason for hiding this comment

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

I just checked, CI indeed did not find the issue.
It seems to be that we really don't run cargo test under valgrind, but just the tests that we run via C++ (e.g. qml_features_test, etc.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could try using: https://github.com/jfrimmel/cargo-valgrind
But that would probably be better served in a different PR, as that means we might want to remove/reduce the qt_types_standalone tests as well 🤔

Copy link
Member

Choose a reason for hiding this comment

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

as an outsider: can you use sanitizers instead? they are much faster and also have leak checking built-in - that should be preferred over valgrind nowadays

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe ? Could be something to investigate if they can be enabled easily in our Cargo and CMake setups :-)

Because the image crate changes versions somewhat frequently, the
features in CXX-Qt are added with explicit image crate versions.
@LeonMatthesKDAB LeonMatthesKDAB enabled auto-merge (rebase) January 29, 2025 15:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
backport-candidate Change which could be backported to the stable series
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants