Skip to content

Commit de91d1c

Browse files
committed
Fix threading violation in project open processors
1 parent 5c28b8a commit de91d1c

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
### Fixed
1212

1313
- Fixed crash when using 3rd party loggers that don't implement `setLevel`. (#8631)
14-
- Fixed "Slow operations are prohibited on EDT" by migrating `FlutterProjectOpenProcessor` to Kotlin and using `openProjectAsync`. (#8629)
14+
- Fixed `IllegalStateException` and "Slow operations are prohibited on EDT" when opening projects by migrating `FlutterProjectOpenProcessor` to Kotlin and using `openProjectAsync`. (#8629)
1515

1616
## 88.1.0
1717

src/io/flutter/editor/FlutterStudioProjectOpenProcessor.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ class FlutterStudioProjectOpenProcessor : FlutterProjectOpenProcessor() {
2828
override val name: String
2929
get() = "Flutter Studio"
3030

31-
override fun canOpenProject(file: VirtualFile): Boolean {
32-
val root = PubRoot.forDirectory(file)
33-
return root != null && root.declaresFlutter()
34-
}
31+
override fun canOpenProject(file: VirtualFile): Boolean =
32+
PubRoot.forDirectory(file)?.declaresFlutter() == true
3533

3634
/**
3735
* Replaces the deprecated `doOpenProject`.
@@ -57,16 +55,16 @@ class FlutterStudioProjectOpenProcessor : FlutterProjectOpenProcessor() {
5755
return newProject
5856
}
5957

60-
writeAction {
61-
for (module in FlutterModuleUtils.getModules(newProject)) {
62-
if (FlutterModuleUtils.declaresFlutter(module) && !FlutterModuleUtils.isFlutterModule(module)) {
58+
for (module in FlutterModuleUtils.getModules(newProject)) {
59+
if (FlutterModuleUtils.declaresFlutter(module) && !FlutterModuleUtils.isFlutterModule(module)) {
60+
writeAction {
6361
FlutterModuleUtils.setFlutterModuleType(module)
64-
FlutterModuleUtils.enableDartSDK(module)
6562
}
63+
FlutterModuleUtils.enableDartSDK(module)
6664
}
67-
newProject.save()
68-
EditorNotifications.getInstance(newProject).updateAllNotifications()
6965
}
66+
newProject.save()
67+
EditorNotifications.getInstance(newProject).updateAllNotifications()
7068

7169
return newProject
7270
}

src/io/flutter/project/FlutterProjectOpenProcessor.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ open class FlutterProjectOpenProcessor : ProjectOpenProcessor() {
6767
if (project == null || project.isDisposed) return project
6868

6969
// Convert any modules that use Flutter but don't have IntelliJ Flutter metadata.
70-
writeAction {
71-
convertToFlutterProject(project)
72-
}
70+
convertToFlutterProject(project)
7371

7472
return project
7573
}

src/io/flutter/utils/FlutterModuleUtils.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,14 @@ public static void setFlutterModuleType(@NotNull Module module) {
375375

376376
public static void setFlutterModuleAndReload(@NotNull Module module, @NotNull Project project) {
377377
if (project.isDisposed()) return;
378+
ApplicationManager.getApplication().invokeLater(() -> {
379+
ApplicationManager.getApplication().runWriteAction(() -> setFlutterModuleType(module));
380+
enableDartSDK(module);
381+
project.save();
378382

379-
setFlutterModuleType(module);
380-
enableDartSDK(module);
381-
project.save();
382-
383-
EditorNotifications.getInstance(project).updateAllNotifications();
384-
ProjectManager.getInstance().reloadProject(project);
383+
EditorNotifications.getInstance(project).updateAllNotifications();
384+
ProjectManager.getInstance().reloadProject(project);
385+
});
385386
}
386387

387388
public static void enableDartSDK(final @NotNull Module module) {

0 commit comments

Comments
 (0)