Merge branch 'fix/exit-dialog' into 'master'

Fix: client.isRunning will answer if the client is 'alive' not if it rendering something.

See merge request sheepitrenderfarm/client!205
This commit is contained in:
harlekin
2023-03-07 08:44:24 +00:00

View File

@@ -33,6 +33,7 @@ import java.awt.Image;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@@ -519,7 +520,7 @@ public class Working implements Activity {
} }
private int getJobsQueueSize(Client client) { private int getJobsQueueSize(Client client) {
return client.getUploadQueueSize() + (client.isRunning() ? 1 : 0); return client.getUploadQueueSize() + (client.getRenderingJob() != null ? 1 : 0);
} }
class PauseAction implements ActionListener { class PauseAction implements ActionListener {
@@ -571,13 +572,17 @@ public class Working implements Activity {
} }
public int showCloseDialog(int jobsQueueSize) { public int showCloseDialog(int jobsQueueSize) {
String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" }; ArrayList<String> exitJobOptions = new ArrayList<String>();
return JOptionPane.showOptionDialog(null, String.format( if (jobsQueueSize > 0) {
"<html>You have <strong>%d frame%s</strong> being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n", exitJobOptions.add("Exit after current Jobs");
jobsQueueSize, // Add the current frame to the total count ONLY if the client is running }
(jobsQueueSize > 1 ? "s" : ""), (jobsQueueSize > 1 ? (jobsQueueSize + " ") : ""), (jobsQueueSize > 1 ? "s" : "")), exitJobOptions.add("Exit Immediately");
"Exit Now or Later", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions, exitJobOptions.add("Do Nothing");
exitJobOptions[2]); // Make the "Do nothing" button the default one to avoid mistakes
String message = jobsQueueSize == 0 ? "Do you want to exit now?" : String.format("<html>You have <strong>%d frame%s</strong> being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n", jobsQueueSize, (jobsQueueSize > 1 ? "s" : ""));
return JOptionPane.showOptionDialog(null, message, "Exit Now or Later?",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions.toArray(), exitJobOptions.size() - 1); // Make the "Do nothing" button the default one to avoid mistakes
} }
public void finishJobBeforeExit(Client client, int jobsQueueSize) { public void finishJobBeforeExit(Client client, int jobsQueueSize) {