mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
DocLoader: Ensure the isolate has been properly started
It seems that sometimes _sendPort is null. I'm not sure why. In those cases lets try to reinitialize the isolate. Fixes APP-2W
This commit is contained in:
@ -14,10 +14,14 @@ class MdYamlDocLoader {
|
||||
var _loadingLock = Lock();
|
||||
|
||||
Future<void> _initIsolate() async {
|
||||
if (_isolate != null) return;
|
||||
if (_isolate != null && _sendPort != null) return;
|
||||
|
||||
return await _loadingLock.synchronized(() async {
|
||||
if (_isolate != null) return;
|
||||
if (_isolate != null && _sendPort != null) return;
|
||||
if (_isolate != null) {
|
||||
_isolate.kill(priority: Isolate.immediate);
|
||||
_isolate = null;
|
||||
}
|
||||
_isolate = await Isolate.spawn(_isolateMain, _receivePort.sendPort);
|
||||
|
||||
var data = await _receivePort.first;
|
||||
|
Reference in New Issue
Block a user