|
5 | 5 | */
|
6 | 6 | package io.flutter.run;
|
7 | 7 |
|
8 |
| -import com.intellij.execution.*; |
| 8 | +import com.intellij.execution.DefaultExecutionResult; |
| 9 | +import com.intellij.execution.ExecutionException; |
| 10 | +import com.intellij.execution.ExecutionResult; |
| 11 | +import com.intellij.execution.Executor; |
9 | 12 | import com.intellij.execution.configurations.CommandLineState;
|
10 | 13 | import com.intellij.execution.configurations.GeneralCommandLine;
|
11 | 14 | import com.intellij.execution.configurations.RunProfile;
|
|
21 | 24 | import com.intellij.execution.ui.ConsoleView;
|
22 | 25 | import com.intellij.execution.ui.ConsoleViewContentType;
|
23 | 26 | import com.intellij.execution.ui.RunContentDescriptor;
|
| 27 | +import com.intellij.execution.ui.RunContentManager; |
24 | 28 | import com.intellij.icons.AllIcons;
|
25 | 29 | import com.intellij.openapi.actionSystem.AnAction;
|
26 | 30 | import com.intellij.openapi.actionSystem.Separator;
|
@@ -389,7 +393,7 @@ protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNul
|
389 | 393 |
|
390 | 394 | // See if we should issue a hot-reload.
|
391 | 395 | final List<RunContentDescriptor> runningProcesses =
|
392 |
| - ExecutionManager.getInstance(env.getProject()).getContentManager().getAllDescriptors(); |
| 396 | + RunContentManager.getInstance(env.getProject()).getAllDescriptors(); |
393 | 397 |
|
394 | 398 | final ProcessHandler process = getRunningAppProcess(launchState.runConfig);
|
395 | 399 | if (process != null) {
|
@@ -446,15 +450,18 @@ private String getSelectedDeviceId(@NotNull Project project) {
|
446 | 450 | * Returns the currently running app for the given RunConfig, if any.
|
447 | 451 | */
|
448 | 452 | @Nullable
|
449 |
| - public static ProcessHandler getRunningAppProcess(RunConfig config) { |
| 453 | + public static ProcessHandler getRunningAppProcess(@NotNull RunConfig config) { |
450 | 454 | final Project project = config.getProject();
|
451 |
| - final List<RunContentDescriptor> runningProcesses = |
452 |
| - ExecutionManager.getInstance(project).getContentManager().getAllDescriptors(); |
| 455 | + if (project != null) { |
| 456 | + final List<RunContentDescriptor> runningProcesses = |
| 457 | + RunContentManager.getInstance(project).getAllDescriptors(); |
453 | 458 |
|
454 |
| - for (RunContentDescriptor descriptor : runningProcesses) { |
455 |
| - final ProcessHandler process = descriptor.getProcessHandler(); |
456 |
| - if (process != null && !process.isProcessTerminated() && process.getUserData(FLUTTER_RUN_CONFIG_KEY) == config) { |
457 |
| - return process; |
| 459 | + for (RunContentDescriptor descriptor : runningProcesses) { |
| 460 | + if (descriptor == null) continue; |
| 461 | + final ProcessHandler process = descriptor.getProcessHandler(); |
| 462 | + if (process != null && !process.isProcessTerminated() && process.getUserData(FLUTTER_RUN_CONFIG_KEY) == config) { |
| 463 | + return process; |
| 464 | + } |
458 | 465 | }
|
459 | 466 | }
|
460 | 467 |
|
|
0 commit comments