Skip to content

Commit db6615c

Browse files
authored
Add a forceLoad option to property editor (#8268)
The property editor was sometimes failing to load. I think this was the repro: 1. Open a project (property editor will load) 2. Close the project 3. Open the project again (property editor fails to load) It seems the static var is set to null only on IJ first startup, not on project open. There may be a better way to fix this but I'm not sure what it is yet.
1 parent 3f5fe4d commit db6615c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

flutter-idea/src/io/flutter/propertyeditor/PropertyEditorViewFactory.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,35 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
7373
return;
7474
}
7575

76-
checkDockedUnpinnedAndCreateContent(project, toolWindow);
76+
checkDockedUnpinnedAndCreateContent(project, toolWindow, true);
7777

7878
final PropertyEditorViewFactory self = this;
7979
MessageBusConnection connection = project.getMessageBus().connect();
8080
connection.subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() {
8181
@Override
8282
public void toolWindowShown(@NotNull ToolWindow activatedToolWindow) {
8383
if (activatedToolWindow.getId().equals(getToolWindowId())) {
84-
checkDockedUnpinnedAndCreateContent(project, toolWindow);
84+
checkDockedUnpinnedAndCreateContent(project, toolWindow, false);
8585
}
8686
}
8787

8888
@Override
8989
public void stateChanged(@NotNull ToolWindowManager toolWindowManager, @NotNull ToolWindowManagerEventType changeType) {
9090
if (changeType.equals(ToolWindowManagerEventType.SetToolWindowAutoHide) ||
9191
changeType.equals(ToolWindowManagerEventType.SetToolWindowType)) {
92-
checkDockedUnpinnedAndCreateContent(project, toolWindow);
92+
checkDockedUnpinnedAndCreateContent(project, toolWindow, false);
9393
}
9494
}
9595
});
9696
Disposer.register(toolWindow.getDisposable(), connection);
9797
}
9898

99-
private void checkDockedUnpinnedAndCreateContent(@NotNull Project project, ToolWindow toolWindow) {
99+
private void checkDockedUnpinnedAndCreateContent(@NotNull Project project, ToolWindow toolWindow, boolean forceLoad) {
100100
final Boolean isDockedUnpinned = toolWindow.getType().equals(ToolWindowType.DOCKED) && toolWindow.isAutoHide();
101-
if (!isDockedUnpinned.equals(previousDockedUnpinned)) {
101+
102+
// If this is the first time we are loading the content, force a load even if docked unpinned state matches.
103+
// Docked unpinned state is only null the first time application is opened (I think).
104+
if (!isDockedUnpinned.equals(previousDockedUnpinned) || forceLoad) {
102105
previousDockedUnpinned = isDockedUnpinned;
103106
super.createToolWindowContent(project, toolWindow, isDockedUnpinned
104107
? "This tool window is in \"Docked Unpinned\" mode, which means it will disappear "

0 commit comments

Comments
 (0)