please die on close

This commit is contained in:
rusefillc 2020-10-08 23:23:45 -04:00
parent 2cb665cc51
commit 804d883ea4
3 changed files with 15 additions and 3 deletions

View File

@ -1,8 +1,10 @@
package com.rusefi.ui.util;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Arrays;
/**
* Date: 3/24/13
@ -38,6 +40,11 @@ public class FrameHelper {
@Override
public void windowClosed(WindowEvent ev) {
onWindowClosed();
for (Thread t : Thread.getAllStackTraces().keySet()) {
if (!t.isDaemon())
System.out.println("Non-daemon thread: " + t);
}
System.out.println(Arrays.toString(Frame.getFrames()));
}
});
frame.add(component);

View File

@ -5,6 +5,7 @@ import com.efiAnalytics.plugin.ecu.ControllerException;
import com.efiAnalytics.plugin.ecu.ControllerParameterChangeListener;
import com.opensr5.ini.IniFileModel;
import com.opensr5.ini.field.IniField;
import com.rusefi.NamedThreadFactory;
import com.rusefi.TsTuneReader;
import com.rusefi.config.generated.Fields;
import com.rusefi.tools.online.Online;
@ -21,6 +22,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ThreadFactory;
import java.util.function.Supplier;
/**
@ -30,6 +32,7 @@ public class TuneUploadTab {
private final JComponent content = new JPanel(new VerticalFlowLayout());
// 2 seconds aggregation by default
private static final int AUTO_UPDATE_AGGREGATION = Integer.parseInt(System.getProperty("autoupload.aggregation", "2000"));
private static final ThreadFactory THREAD_FACTORY = new NamedThreadFactory("Tune Upload", true);
private static final String REO_URL = "https://rusefi.com/online/";
private final AuthTokenPanel tokenPanel = new AuthTokenPanel();
@ -69,7 +72,7 @@ public class TuneUploadTab {
};
upload.setBackground(new Color(0x90EE90));
Thread t = new Thread(new Runnable() {
Thread t = THREAD_FACTORY.newThread(new Runnable() {
@Override
public void run() {
while (true) {
@ -98,7 +101,6 @@ public class TuneUploadTab {
}
}
});
t.setDaemon(true);
t.start();
upload.addActionListener(new AbstractAction() {

View File

@ -7,6 +7,7 @@ import com.opensr5.ini.IniFileModel;
import com.rusefi.TsTuneReader;
import com.rusefi.ui.util.FrameHelper;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Objects;
@ -38,7 +39,9 @@ public class PluginBodySandbox {
doReturn(new String[]{PROJECT_NAME}).when(controllerAccess).getEcuConfigurationNames();
doReturn(controllerParameterServer).when(controllerAccess).getControllerParameterServer();
new FrameHelper().showFrame(new PluginEntry(() -> controllerAccess).getContent());
FrameHelper frameHelper = new FrameHelper();
frameHelper.getFrame().setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
frameHelper.showFrame(new PluginEntry(() -> controllerAccess).getContent());
}
}