mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[threading] IJPL-192699 IJ-CR-166168: Prevent possible NPE with absent root pane
GitOrigin-RevId: d6df9bde5dd6b538f8680035927cdf43381ca0f1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
db6e1b33d2
commit
8ec8ea62b2
@@ -26,7 +26,6 @@ import kotlinx.coroutines.future.asCompletableFuture
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.AWTEvent
|
||||
import java.awt.Component
|
||||
import java.awt.KeyboardFocusManager
|
||||
import java.awt.event.InvocationEvent
|
||||
import java.awt.event.KeyEvent
|
||||
@@ -34,6 +33,7 @@ import java.awt.event.MouseEvent
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import javax.swing.JFrame
|
||||
import javax.swing.JRootPane
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
/**
|
||||
@@ -107,12 +107,12 @@ object SuvorovProgress {
|
||||
processInvocationEventsWithoutDialog(awaitedValue, Int.MAX_VALUE)
|
||||
}
|
||||
"NiceOverlay" -> {
|
||||
val currentFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner
|
||||
if (currentFocusOwner == null) {
|
||||
val currentFocusedPane = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner?.let(SwingUtilities::getRootPane)
|
||||
if (currentFocusedPane == null) {
|
||||
// can happen also in tests
|
||||
processInvocationEventsWithoutDialog(awaitedValue, Int.MAX_VALUE)
|
||||
} else {
|
||||
showNiceOverlay(awaitedValue, currentFocusOwner)
|
||||
showNiceOverlay(awaitedValue, currentFocusedPane)
|
||||
}
|
||||
}
|
||||
"Bar", "Overlay" -> showPotemkinProgress(awaitedValue, isBar = value == "Bar")
|
||||
@@ -120,8 +120,8 @@ object SuvorovProgress {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showNiceOverlay(awaitedValue: Deferred<*>, currentFocusOwner: Component) {
|
||||
val niceOverlay = NiceOverlayUi(currentFocusOwner, false)
|
||||
private fun showNiceOverlay(awaitedValue: Deferred<*>, rootPane: JRootPane) {
|
||||
val niceOverlay = NiceOverlayUi(rootPane, false)
|
||||
|
||||
val disposable = Disposer.newDisposable()
|
||||
val stealer = PotemkinProgress.startStealingInputEvents(
|
||||
|
||||
@@ -36,7 +36,7 @@ import javax.swing.UIManager
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
class NiceOverlayUi(
|
||||
component: Component,
|
||||
val rootPane: JRootPane,
|
||||
/**
|
||||
* "Close" button requires making a screenshot (see [com.intellij.openapi.progress.util.ui.NiceOverlayUi.screenshot])
|
||||
* The screenshot via Robot provokes an alert on MacOS, and it does not work nice on multi-monitor linux setup
|
||||
@@ -44,7 +44,6 @@ class NiceOverlayUi(
|
||||
*/
|
||||
val showCloseButton: Boolean,
|
||||
) {
|
||||
private val rootPane: JRootPane = SwingUtilities.getRootPane(component)
|
||||
|
||||
|
||||
private val mainText = DiagnosticBundle.message("freeze.popup.application.is.not.responding", ApplicationInfo.getInstance().versionName)
|
||||
|
||||
Reference in New Issue
Block a user