Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/io/flutter/run/FlutterAppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public void dispose() {
*/
@Nullable
public FlutterApp getActiveApp() {
final RunContentDescriptor descriptor = getRunContentManager().getSelectedContent();
RunContentManager mgr = getRunContentManager();
if (mgr == null) {
return null;
}
final RunContentDescriptor descriptor = mgr.getSelectedContent();
if (descriptor == null) {
return null;
}
Expand All @@ -84,9 +88,12 @@ public EventStream<FlutterApp> getActiveAppAsStream() {
*/
public List<FlutterApp> getApps() {
final List<FlutterApp> apps = new ArrayList<>();
RunContentManager mgr = getRunContentManager();
if (mgr == null) {
return apps;
}

final List<RunContentDescriptor> runningProcesses =
getRunContentManager().getAllDescriptors();
final List<RunContentDescriptor> runningProcesses = mgr.getAllDescriptors();
for (RunContentDescriptor descriptor : runningProcesses) {
final ProcessHandler process = descriptor.getProcessHandler();
if (process != null) {
Expand All @@ -109,7 +116,13 @@ private void updateActiveApp() {
}
}

@Nullable
private RunContentManager getRunContentManager() {
// Creating a RunContentManager causes a blank window to appear, so don't create it here.
// See https://github.com/flutter/flutter-intellij/issues/4217
if (ServiceManager.getServiceIfCreated(project, RunContentManager.class) == null) {
return null;
}
return ExecutionManager.getInstance(project).getContentManager();
}
}