fix rare flutter_tools logging crash in daemon mode (#14401)

* Populate AnsiTerminal in context for daemon launches

* Strip out AnsiTerminal additions to context since they are no longer needed
This commit is contained in:
jcollins-g 2018-02-01 09:30:53 -08:00 committed by GitHub
parent 51158c9177
commit c81a5ed09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 9 deletions

View File

@ -15,7 +15,6 @@ import '../lib/src/base/io.dart';
import '../lib/src/base/logger.dart';
import '../lib/src/base/os.dart';
import '../lib/src/base/platform.dart';
import '../lib/src/base/terminal.dart';
import '../lib/src/cache.dart';
import '../lib/src/disabled_usage.dart';
import '../lib/src/flx.dart';
@ -50,7 +49,6 @@ Future<Null> main(List<String> args) async {
context.putIfAbsent(Platform, () => const LocalPlatform());
context.putIfAbsent(FileSystem, () => const LocalFileSystem());
context.putIfAbsent(ProcessManager, () => const LocalProcessManager());
context.putIfAbsent(AnsiTerminal, () => new AnsiTerminal());
context.putIfAbsent(Logger, () => new StdoutLogger());
context.putIfAbsent(Cache, () => new Cache());
context.putIfAbsent(Config, () => new Config());

View File

@ -17,7 +17,6 @@ import '../lib/src/base/io.dart';
import '../lib/src/base/logger.dart';
import '../lib/src/base/os.dart';
import '../lib/src/base/platform.dart';
import '../lib/src/base/terminal.dart';
import '../lib/src/cache.dart';
import '../lib/src/dart/package_map.dart';
import '../lib/src/disabled_usage.dart';
@ -46,7 +45,6 @@ Future<Null> main(List<String> args) async {
context.putIfAbsent(Platform, () => const LocalPlatform());
context.putIfAbsent(FileSystem, () => const LocalFileSystem());
context.putIfAbsent(ProcessManager, () => const LocalProcessManager());
context.putIfAbsent(AnsiTerminal, () => new AnsiTerminal());
context.putIfAbsent(Logger, () => new StdoutLogger());
context.putIfAbsent(Cache, () => new Cache());
context.putIfAbsent(Config, () => new Config());

View File

@ -18,7 +18,6 @@ import 'src/base/io.dart';
import 'src/base/logger.dart';
import 'src/base/platform.dart';
import 'src/base/process.dart';
import 'src/base/terminal.dart';
import 'src/base/utils.dart';
import 'src/cache.dart';
import 'src/crash_reporting.dart';
@ -68,7 +67,6 @@ Future<int> run(
context.putIfAbsent(Platform, () => const LocalPlatform());
context.putIfAbsent(FileSystem, () => const LocalFileSystem());
context.putIfAbsent(ProcessManager, () => const LocalProcessManager());
context.putIfAbsent(AnsiTerminal, () => new AnsiTerminal());
context.putIfAbsent(Logger, () => platform.isWindows ? new WindowsStdoutLogger() : new StdoutLogger());
context.putIfAbsent(Config, () => new Config());

View File

@ -15,7 +15,7 @@ import 'platform.dart';
final AnsiTerminal _kAnsiTerminal = new AnsiTerminal();
AnsiTerminal get terminal {
return context == null
return (context == null || context[AnsiTerminal] == null)
? _kAnsiTerminal
: context[AnsiTerminal];
}

View File

@ -13,7 +13,6 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/port_scanner.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
@ -42,7 +41,6 @@ typedef void ContextInitializer(AppContext testContext);
void _defaultInitializeContext(AppContext testContext) {
testContext
..putIfAbsent(AnsiTerminal, () => new AnsiTerminal())
..putIfAbsent(DeviceManager, () => new MockDeviceManager())
..putIfAbsent(DevFSConfig, () => new DevFSConfig())
..putIfAbsent(Doctor, () => new MockDoctor())