Prevent multiple concurrent 'checkHideNonConfiguredNotifications' calls
This commit is contained in:
+15
-7
@@ -23,6 +23,7 @@ import com.intellij.openapi.module.Module
|
|||||||
import com.intellij.openapi.project.DumbService
|
import com.intellij.openapi.project.DumbService
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification
|
import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
object ConfigureKotlinNotificationManager: KotlinSingleNotificationManager<ConfigureKotlinNotification> {
|
object ConfigureKotlinNotificationManager: KotlinSingleNotificationManager<ConfigureKotlinNotification> {
|
||||||
@@ -66,16 +67,23 @@ interface KotlinSingleNotificationManager<in T: Notification> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val checkInProgress = AtomicBoolean(false)
|
||||||
|
|
||||||
fun checkHideNonConfiguredNotifications(project: Project) {
|
fun checkHideNonConfiguredNotifications(project: Project) {
|
||||||
if (ConfigureKotlinNotificationManager.getVisibleNotifications(project).isNotEmpty()) {
|
if (checkInProgress.get() || ConfigureKotlinNotificationManager.getVisibleNotifications(project).isEmpty()) return
|
||||||
ApplicationManager.getApplication().executeOnPooledThread {
|
|
||||||
DumbService.getInstance(project).waitForSmartMode()
|
ApplicationManager.getApplication().executeOnPooledThread {
|
||||||
if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) {
|
if (!checkInProgress.compareAndSet(false, true)) return@executeOnPooledThread
|
||||||
ApplicationManager.getApplication().invokeLater {
|
|
||||||
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
DumbService.getInstance(project).waitForSmartMode()
|
||||||
}
|
if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) {
|
||||||
|
ApplicationManager.getApplication().invokeLater {
|
||||||
|
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
||||||
|
checkInProgress.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
checkInProgress.set(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user