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