修改主窗口关闭后进程残留的问题

main
lensfrex 4 years ago
parent f7576885fd
commit 9306f3275f
No known key found for this signature in database
GPG Key ID: E10FF75B77E1924D
  1. 1
      .gitignore
  2. 21
      Dogename/src/main/java/me/lensferno/dogename/Main.java
  3. 2
      Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java

1
.gitignore vendored

@ -7,3 +7,4 @@ target
log
logs
.idea
process

@ -12,6 +12,8 @@ import me.lensferno.dogename.sayings.Hitokoto;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.util.Random;
public class Main extends Application {
@ -22,6 +24,20 @@ public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
new File("process").mkdirs();
File tempFile = new File("process" + File.separator + pid);
tempFile.createNewFile();
tempFile.deleteOnExit();
}catch (Exception e){
e.printStackTrace();
}
FXMLLoader fxmlLoader;
Parent parent;
@ -51,7 +67,10 @@ public class Main extends Application {
mainInterfaceController.setImg(DataReleaser.getMainPicStream());
primaryStage.setOnCloseRequest(event -> configLoader.writeAllConfigToFile(configLoader.getMainConfigLocation(),configLoader.getVoiceConfigLocation()));
primaryStage.setOnCloseRequest(event -> {
configLoader.writeAllConfigToFile(configLoader.getMainConfigLocation(), configLoader.getVoiceConfigLocation());
System.exit(0);
});
if (mainInterfaceController.getMainConfig().isShowSaying()) {
if (new Random().nextBoolean()){

@ -183,7 +183,7 @@ public final class MainInterfaceController {
miniPaneController.setListeners();
miniStage.show();
currentStage.close();
currentStage.hide();
}

Loading…
Cancel
Save