mirror of https://github.com/AMT-Cheif/drift.git
Fix crash when database is closed with asserts disabled
This commit is contained in:
parent
cf607f0108
commit
41b32b1684
|
@ -61,7 +61,7 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser
|
|||
final count = ++_openedDbCount[runtimeType];
|
||||
if (count > 1) {
|
||||
print(
|
||||
'WARNING (moor): It looks like you\'ve created the database '
|
||||
'WARNING (moor): It looks like you\'ve created the database class'
|
||||
'$runtimeType multiple times. When these two databases use the same '
|
||||
'QueryExecutor, race conditions will ocur and might corrupt the '
|
||||
'database. \n'
|
||||
|
@ -124,6 +124,9 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser
|
|||
/// Closes this database and releases associated resources.
|
||||
Future<void> close() async {
|
||||
await executor.close();
|
||||
_openedDbCount[runtimeType]--;
|
||||
|
||||
if (_openedDbCount[runtimeType] != null) {
|
||||
_openedDbCount[runtimeType]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue