mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-26 08:54:42 +01:00
Fix error in bloc after closed causing stack overflow
This commit is contained in:
parent
067b6a1a60
commit
4762ad02bd
1 changed files with 9 additions and 1 deletions
|
@ -60,7 +60,14 @@ class _Bloc extends Bloc<_Event, _State> {
|
|||
|
||||
@override
|
||||
void onError(Object error, StackTrace stackTrace) {
|
||||
add(_SetError(error, stackTrace));
|
||||
// we need this to prevent onError being triggered recursively
|
||||
if (!isClosed && !_isHandlingError) {
|
||||
_isHandlingError = true;
|
||||
try {
|
||||
add(_SetError(error, stackTrace));
|
||||
} catch (_) {}
|
||||
_isHandlingError = false;
|
||||
}
|
||||
super.onError(error, stackTrace);
|
||||
}
|
||||
|
||||
|
@ -144,4 +151,5 @@ class _Bloc extends Bloc<_Event, _State> {
|
|||
final CollectionsController collectionsController;
|
||||
|
||||
StreamSubscription? _collectionControllerSubscription;
|
||||
var _isHandlingError = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue