ScriptDependenciesLoader: Fix freeze on notifyRootsChanged
In4f3f4dd, launch(EDT(project)) was replaced with TransactionGuard.submitTransaction to fix write in write-unsafe context. Unfortunately submitTransaction will call action immediately if we are already on EDT. This causes IDE freeze. By replacing submitTransaction with submitTransactionLater we are postponing work to the end of events queue (as it was before4f3f4dd). Also in isUnitTestMode we need to call action immediately as it was before4f3f4dd. #KT-25958 Fixed
This commit is contained in:
committed by
Sergey Rostov
parent
ddb034715d
commit
81b519286f
+8
-2
@@ -109,13 +109,19 @@ abstract class ScriptDependenciesLoader(
|
||||
protected fun notifyRootsChanged() {
|
||||
if (!shouldNotifyRootsChanged) return
|
||||
|
||||
TransactionGuard.submitTransaction(project, Runnable {
|
||||
val doNotifyRootsChanged = Runnable {
|
||||
runWriteAction {
|
||||
if (project.isDisposed) return@runWriteAction
|
||||
|
||||
ProjectRootManagerEx.getInstanceEx(project)?.makeRootsChange(EmptyRunnable.getInstance(), false, true)
|
||||
ScriptDependenciesModificationTracker.getInstance(project).incModificationCount()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
doNotifyRootsChanged.run()
|
||||
} else {
|
||||
TransactionGuard.getInstance().submitTransactionLater(project, doNotifyRootsChanged)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user