use void callback for setBackgroundImage to correctly free pointer after dispatch

This commit is contained in:
Nick Fisher
2024-04-20 13:46:10 +08:00
parent 49229f8c88
commit 15882891e2
4 changed files with 12 additions and 6 deletions

View File

@@ -307,9 +307,12 @@ FLUTTER_PLUGIN_EXPORT void clear_background_image_ffi(void *const viewer) {
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer,
const char *path,
bool fillHeight) {
bool fillHeight, void (*callback)()) {
std::packaged_task<void()> lambda(
[=] { set_background_image(viewer, path, fillHeight); });
[=] {
set_background_image(viewer, path, fillHeight);
callback();
});
auto fut = _rl->add_task(lambda);
}
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer,