fix an issue where --hot would not exit (#5421)
* fix an issue where --hot would not exit * add type annotations
This commit is contained in:
@@ -264,9 +264,9 @@ class DevFS {
|
||||
return _baseUri;
|
||||
}
|
||||
|
||||
Future<dynamic> destroy() async {
|
||||
Future<dynamic> destroy() {
|
||||
printTrace('DevFS: Deleted filesystem on the device ($_baseUri)');
|
||||
return await _operations.destroy(fsName);
|
||||
return _operations.destroy(fsName);
|
||||
}
|
||||
|
||||
void _reset() {
|
||||
|
||||
@@ -295,7 +295,7 @@ class HotRunner extends ResidentRunner {
|
||||
}
|
||||
|
||||
await viewManager.refresh();
|
||||
printStatus('Connected to view: ${viewManager.mainView}');
|
||||
printStatus('Connected to view \'${viewManager.mainView}\'.');
|
||||
|
||||
printStatus('Running ${getDisplayPath(_mainPath)} on ${device.name}...');
|
||||
_loaderShowMessage('Launching...');
|
||||
@@ -313,7 +313,7 @@ class HotRunner extends ResidentRunner {
|
||||
// Finish the file sync now.
|
||||
await _updateDevFS();
|
||||
|
||||
return await waitForAppToFinish();
|
||||
return waitForAppToFinish();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -375,9 +375,8 @@ class HotRunner extends ResidentRunner {
|
||||
}
|
||||
|
||||
Future<Null> _evictDirtyAssets() async {
|
||||
if (_devFS.dirtyAssetEntries.length == 0) {
|
||||
if (_devFS.dirtyAssetEntries.length == 0)
|
||||
return;
|
||||
}
|
||||
if (serviceProtocol.firstIsolateId == null)
|
||||
throw 'Application isolate not found';
|
||||
for (DevFSEntry entry in _devFS.dirtyAssetEntries) {
|
||||
@@ -388,8 +387,12 @@ class HotRunner extends ResidentRunner {
|
||||
|
||||
Future<Null> _cleanupDevFS() async {
|
||||
if (_devFS != null) {
|
||||
// Cleanup the devFS.
|
||||
await _devFS.destroy();
|
||||
// Cleanup the devFS; don't wait indefinitely, and ignore any errors.
|
||||
await _devFS.destroy()
|
||||
.timeout(new Duration(milliseconds: 250))
|
||||
.catchError((dynamic error) {
|
||||
printTrace('$error');
|
||||
});
|
||||
}
|
||||
_devFS = null;
|
||||
}
|
||||
@@ -499,9 +502,8 @@ class HotRunner extends ResidentRunner {
|
||||
|
||||
@override
|
||||
void printHelp() {
|
||||
printStatus('Type "h" or F1 for this help message. Type "q", F10, or ctrl-c to quit.', emphasis: true);
|
||||
printStatus('Type "r" or F5 to perform a hot reload of the app.', emphasis: true);
|
||||
printStatus('Type "R" to restart the app', emphasis: true);
|
||||
printStatus('Type "h" or F1 for this help message; type "q", F10, or ctrl-c to quit.', emphasis: true);
|
||||
printStatus('Type "r" or F5 to perform a hot reload of the app, and "R" to restart the app.', emphasis: true);
|
||||
printStatus('Type "w" to print the widget hierarchy of the app, and "t" for the render tree.', emphasis: true);
|
||||
}
|
||||
|
||||
@@ -511,6 +513,9 @@ class HotRunner extends ResidentRunner {
|
||||
await stopApp();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> preStop() => _cleanupDevFS();
|
||||
|
||||
@override
|
||||
Future<Null> cleanupAtFinish() async {
|
||||
await _cleanupDevFS();
|
||||
|
||||
@@ -43,6 +43,7 @@ abstract class ResidentRunner {
|
||||
|
||||
Future<Null> stop() async {
|
||||
await stopEchoingDeviceLog();
|
||||
await preStop();
|
||||
return stopApp();
|
||||
}
|
||||
|
||||
@@ -127,7 +128,7 @@ abstract class ResidentRunner {
|
||||
return true;
|
||||
} else if (lower == 'q' || character == AnsiTerminal.KEY_F10) {
|
||||
// F10, exit
|
||||
await stopApp();
|
||||
await stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,15 +172,16 @@ abstract class ResidentRunner {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
Future<Null> stopApp() {
|
||||
Future<Null> preStop() async { }
|
||||
|
||||
Future<Null> stopApp() async {
|
||||
if (serviceProtocol != null && !serviceProtocol.isClosed) {
|
||||
if (serviceProtocol.isolates.isNotEmpty) {
|
||||
serviceProtocol.flutterExit(serviceProtocol.firstIsolateId);
|
||||
return new Future<Null>.delayed(new Duration(milliseconds: 100));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 100));
|
||||
}
|
||||
}
|
||||
appFinished();
|
||||
return new Future<Null>.value();
|
||||
}
|
||||
|
||||
/// Called when a signal has requested we exit.
|
||||
|
||||
@@ -213,7 +213,7 @@ class RunAndStayResident extends ResidentRunner {
|
||||
stop();
|
||||
}
|
||||
|
||||
return await waitForAppToFinish();
|
||||
return waitForAppToFinish();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user