mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Better fix for IDEA-78716 Master password prompt is "hidden"
Don't call invoke and wait in AWT, just run in that case. Introduced GuiUtils.invokeAndWaitIfNeeded for this purpose, since we don't have a fair method in utils which invokes Application#invokeAndWait. It still leads to an assertion error in Settings | GitHub, the fix for the assertion will follow in the next commit.
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
@@ -382,4 +383,18 @@ public class GuiUtils {
|
||||
invokeAndWait(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the runnable, if called from the dispatch thread.
|
||||
* Otherwise calls {@link Application#invokeAndWait(Runnable, com.intellij.openapi.application.ModalityState)}
|
||||
*/
|
||||
public static void invokeAndWaitIfNeeded(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
application.invokeAndWait(runnable, modalityState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
@@ -182,7 +183,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
|
||||
}
|
||||
if (key.get() == null) {
|
||||
final Ref<PasswordSafeException> ex = new Ref<PasswordSafeException>();
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
GuiUtils.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
if (key.get() == null) {
|
||||
try {
|
||||
|
||||
+2
-2
@@ -18,12 +18,12 @@ package com.intellij.ide.passwordSafe.ui;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafeException;
|
||||
import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -273,7 +273,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
final AtomicReference<String> pw = new AtomicReference<String>(null);
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
GuiUtils.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
final PasswordSafePromptDialog d = new PasswordSafePromptDialog(project, ps, title, message);
|
||||
if (promptLabel != null) {
|
||||
|
||||
Reference in New Issue
Block a user