Unverified Commit c81a5ed0 authored by jcollins-g's avatar jcollins-g Committed by GitHub

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
parent 51158c91
......@@ -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());
......
......@@ -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());
......
......@@ -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());
......
......@@ -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];
}
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment