Skip to content

Commit aee6b14

Browse files
Merge branch 'gh-252-no-crash-all-exceptions'
2 parents 0098988 + 689ae63 commit aee6b14

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

objectbox/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## latest
22

33
* Require at least Dart SDK 2.14 (shipped with Flutter 2.5.0).
4+
* When using the "All Exceptions" debug option in Visual Studio Code there is no longer an exception
5+
when initializing ObjectBox. #252
46

57
## 1.5.0 (2022-05-11)
68

objectbox/lib/src/native/bindings/bindings.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ ObjectBoxC? _tryObjectBoxLibProcess() {
1919
// [DynamicLibrary.process()] is not supported on windows, see its docs.
2020
if (Platform.isWindows) return null;
2121

22-
ObjectBoxC? obxc;
22+
final DynamicLibrary lib;
2323
try {
24-
_lib = DynamicLibrary.process();
25-
obxc = ObjectBoxC(_lib!);
26-
_isSupportedVersion(obxc); // may throw in case symbols are not found
27-
return obxc;
24+
lib = DynamicLibrary.process();
2825
} catch (_) {
29-
// ignore errors (i.e. symbol not found)
26+
// Ignore errors, caller will try using open.
27+
return null;
28+
}
29+
30+
// Check if the library is actually loaded by searching for a common function.
31+
// Note: not using 'lookup' as its exception if not found is caught if
32+
// All Exceptions is enabled in VS Code.
33+
if (lib.providesSymbol('obx_version')) {
34+
_lib = lib;
35+
return ObjectBoxC(lib);
36+
} else {
3037
return null;
3138
}
3239
}

0 commit comments

Comments
 (0)