use void callback for setBackgroundImage to correctly free pointer after dispatch
This commit is contained in:
@@ -36,7 +36,7 @@ extern "C"
|
||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(void *const viewer, const uint32_t width, const uint32_t height, const float scaleFactor, void (*onComplete)());
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_color_ffi(void *const viewer, const float r, const float g, const float b, const float a);
|
||||
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);
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer, const char *path, bool fillHeight, void (*onComplete)());
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer, float x, float y, bool clamp);
|
||||
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer, int toneMapping);
|
||||
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -531,8 +531,10 @@ class FilamentControllerFFI extends FilamentController {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
final pathPtr = path.toNativeUtf8().cast<Char>();
|
||||
await _withVoidCallback((cb) {
|
||||
set_background_image_ffi(_viewer!, pathPtr, fillHeight, cb);
|
||||
});
|
||||
|
||||
set_background_image_ffi(_viewer!, pathPtr, fillHeight);
|
||||
allocator.free(pathPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1147,13 +1147,14 @@ external void clear_background_image_ffi(
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, ffi.Bool)>(
|
||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Bool, ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(
|
||||
symbol: 'set_background_image_ffi', assetId: 'flutter_filament_plugin')
|
||||
external void set_background_image_ffi(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
ffi.Pointer<ffi.Char> path,
|
||||
bool fillHeight,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
|
||||
Reference in New Issue
Block a user