Another deadlock in console fix #3952
This commit is contained in:
parent
dc824f0c42
commit
43e12e0dc7
|
@ -22,6 +22,7 @@ public class AutoupdateUtil {
|
||||||
private static final String APPICON = "/appicon.png";
|
private static final String APPICON = "/appicon.png";
|
||||||
|
|
||||||
public static JComponent wrap(JComponent component) {
|
public static JComponent wrap(JComponent component) {
|
||||||
|
AutoupdateUtil.assertAwtThread();
|
||||||
JPanel result = new JPanel();
|
JPanel result = new JPanel();
|
||||||
result.add(component);
|
result.add(component);
|
||||||
return result;
|
return result;
|
||||||
|
@ -93,6 +94,7 @@ public class AutoupdateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trueLayout(Component component) {
|
public static void trueLayout(Component component) {
|
||||||
|
assertAwtThread();
|
||||||
if (component == null)
|
if (component == null)
|
||||||
return;
|
return;
|
||||||
component.invalidate();
|
component.invalidate();
|
||||||
|
@ -100,6 +102,11 @@ public class AutoupdateUtil {
|
||||||
component.repaint();
|
component.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void assertAwtThread() {
|
||||||
|
if (!SwingUtilities.isEventDispatchThread())
|
||||||
|
throw new IllegalStateException("Not on AWT thread but " + Thread.currentThread().getName());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasExistingFile(String zipFileName, long completeFileSize, long lastModified) {
|
public static boolean hasExistingFile(String zipFileName, long completeFileSize, long lastModified) {
|
||||||
File file = new File(zipFileName);
|
File file = new File(zipFileName);
|
||||||
System.out.println("We have " + file.length() + " " + new Date(file.lastModified()) + " " + file.getAbsolutePath());
|
System.out.println("We have " + file.length() + " " + new Date(file.lastModified()) + " " + file.getAbsolutePath());
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.rusefi.ui.util.FrameHelper;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
@ -61,9 +62,7 @@ public class MainFrame {
|
||||||
|
|
||||||
private void windowOpenedHandler() {
|
private void windowOpenedHandler() {
|
||||||
setTitle();
|
setTitle();
|
||||||
ConnectionStatusLogic.INSTANCE.addListener(new ConnectionStatusLogic.Listener() {
|
ConnectionStatusLogic.INSTANCE.addListener(isConnected -> SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
|
||||||
public void onConnectionStatus(boolean isConnected) {
|
|
||||||
setTitle();
|
setTitle();
|
||||||
UiUtils.trueRepaint(tabbedPane.tabbedPane); // this would repaint status label
|
UiUtils.trueRepaint(tabbedPane.tabbedPane); // this would repaint status label
|
||||||
if (ConnectionStatusLogic.INSTANCE.getValue() == ConnectionStatusValue.CONNECTED) {
|
if (ConnectionStatusLogic.INSTANCE.getValue() == ConnectionStatusValue.CONNECTED) {
|
||||||
|
@ -73,8 +72,7 @@ public class MainFrame {
|
||||||
" " + withOffset, CommandQueue.DEFAULT_TIMEOUT,
|
" " + withOffset, CommandQueue.DEFAULT_TIMEOUT,
|
||||||
InvocationConfirmationListener.VOID, false);
|
InvocationConfirmationListener.VOID, false);
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
final LinkManager linkManager = consoleUI.uiContext.getLinkManager();
|
final LinkManager linkManager = consoleUI.uiContext.getLinkManager();
|
||||||
linkManager.getConnector().connectAndReadConfiguration(new BinaryProtocol.Arguments(true), new ConnectionStateListener() {
|
linkManager.getConnector().connectAndReadConfiguration(new BinaryProtocol.Arguments(true), new ConnectionStateListener() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.rusefi.ui.util;
|
package com.rusefi.ui.util;
|
||||||
|
|
||||||
import com.rusefi.StartupFrame;
|
|
||||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -17,7 +16,6 @@ import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static com.rusefi.ui.util.LocalizedMessages.CLEAR;
|
import static com.rusefi.ui.util.LocalizedMessages.CLEAR;
|
||||||
|
@ -59,6 +57,7 @@ public class UiUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage getScreenShot(Component component) {
|
private static BufferedImage getScreenShot(Component component) {
|
||||||
|
AutoupdateUtil.assertAwtThread();
|
||||||
// http://stackoverflow.com/questions/5853879/swing-obtain-image-of-jframe/5853992
|
// http://stackoverflow.com/questions/5853879/swing-obtain-image-of-jframe/5853992
|
||||||
BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
|
BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||||
// call the Component's paint method, using
|
// call the Component's paint method, using
|
||||||
|
|
Loading…
Reference in New Issue