Не подтверждена Коммит 9b45662e создал по автору Simon Binder's avatar Simon Binder
Просмотр файлов

Return value from callable to work around VM issue

Due to https://github.com/dart-lang/sdk/issues/56064, Dart stable 3.4
reports an exception on native calls involving `NativeCallable`s
returning `null` (which they do for `void`).
This exception is not critical as it only occurs when a debugger is
attached, but it's still annoying and easy to work around by returning
a bogus value then dropped.

Closes #242
владелец db5077bc
## 2.4.4
- Add a temporary workaround for [a Dart bug](https://github.com/dart-lang/sdk/issues/56064)
causing spurious exceptions when databases are closed and a debugger is attached.
## 2.4.3 ## 2.4.3
- Migrate away from legacy web APIs: `dart:html`, `dart:js`, `dart:indexeddb` - Migrate away from legacy web APIs: `dart:html`, `dart:js`, `dart:indexeddb`
......
...@@ -299,10 +299,13 @@ final class FfiDatabase extends RawSqliteDatabase { ...@@ -299,10 +299,13 @@ final class FfiDatabase extends RawSqliteDatabase {
static Pointer<NativeFunction<Void Function(Pointer<Void>)>> _xDestroy( static Pointer<NativeFunction<Void Function(Pointer<Void>)>> _xDestroy(
List<NativeCallable> callables) { List<NativeCallable> callables) {
void destroy(Pointer<Void> _) { int destroy(Pointer<Void> _) {
for (final callable in callables) { for (final callable in callables) {
callable.close(); callable.close();
} }
// TODO: Remove and change to void after Dart 3.5 or https://github.com/dart-lang/sdk/issues/56064
return 0;
} }
final callable = final callable =
...@@ -711,7 +714,9 @@ extension on RawXFunc { ...@@ -711,7 +714,9 @@ extension on RawXFunc {
NativeCallable<_XFunc> toNative(Bindings bindings) { NativeCallable<_XFunc> toNative(Bindings bindings) {
return NativeCallable.isolateLocal((Pointer<sqlite3_context> ctx, int nArgs, return NativeCallable.isolateLocal((Pointer<sqlite3_context> ctx, int nArgs,
Pointer<Pointer<sqlite3_value>> args) { Pointer<Pointer<sqlite3_value>> args) {
return this(FfiContext(bindings, ctx), _ValueList(nArgs, args, bindings)); this(FfiContext(bindings, ctx), _ValueList(nArgs, args, bindings));
// TODO: Remove and change to void after Dart 3.5 or https://github.com/dart-lang/sdk/issues/56064
return 0;
}) })
..keepIsolateAlive = false; ..keepIsolateAlive = false;
} }
...@@ -721,9 +726,10 @@ extension on RawXFinal { ...@@ -721,9 +726,10 @@ extension on RawXFinal {
NativeCallable<_XFinal> toNative(Bindings bindings, bool clean) { NativeCallable<_XFinal> toNative(Bindings bindings, bool clean) {
return NativeCallable.isolateLocal((Pointer<sqlite3_context> ctx) { return NativeCallable.isolateLocal((Pointer<sqlite3_context> ctx) {
final context = FfiContext(bindings, ctx); final context = FfiContext(bindings, ctx);
final res = this(context); this(context);
if (clean) context.freeContext(); if (clean) context.freeContext();
return res; // TODO: Remove and change to void after Dart 3.5 or https://github.com/dart-lang/sdk/issues/56064
return 0;
}) })
..keepIsolateAlive = false; ..keepIsolateAlive = false;
} }
...@@ -757,12 +763,9 @@ extension on RawUpdateHook { ...@@ -757,12 +763,9 @@ extension on RawUpdateHook {
final tableName = table.readString(); final tableName = table.readString();
this(kind, tableName, rowid); this(kind, tableName, rowid);
// This closure needs to return `void` exactly to make the FFI analyzer // TODO: Remove and change to void after Dart 3.5 or https://github.com/dart-lang/sdk/issues/56064
// happy. return 0;
return _returnsVoid();
}, },
)..keepIsolateAlive = false; )..keepIsolateAlive = false;
} }
static void _returnsVoid() {}
} }
name: sqlite3 name: sqlite3
description: Provides lightweight yet convenient bindings to SQLite by using dart:ffi description: Provides lightweight yet convenient bindings to SQLite by using dart:ffi
version: 2.4.3 version: 2.4.4
homepage: https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3 homepage: https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3
issue_tracker: https://github.com/simolus3/sqlite3.dart/issues issue_tracker: https://github.com/simolus3/sqlite3.dart/issues
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать