Fix #47 User can block a project on his client
This commit is contained in:
@@ -436,7 +436,7 @@ public class Client {
|
||||
// no exception should be raised to actual launcher (applet or standalone)
|
||||
}
|
||||
|
||||
if (error != null && error == Error.Type.RENDERER_CRASHED) {
|
||||
if (error != null && (error == Error.Type.RENDERER_CRASHED || error == Error.Type.RENDERER_KILLED_BY_USER)) {
|
||||
// do nothing, we can ask for a job right away
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Error {
|
||||
RENDERER_CRASHED(12),
|
||||
RENDERER_OUT_OF_VIDEO_MEMORY(13),
|
||||
RENDERER_KILLED(14),
|
||||
RENDERER_KILLED_BY_USER(20),
|
||||
RENDERER_MISSING_LIBRARIES(15),
|
||||
FAILED_TO_EXECUTE(16),
|
||||
OS_NOT_SUPPORTED(17),
|
||||
@@ -152,6 +153,8 @@ public class Error {
|
||||
return "Failed to launch renderer. Please check if you have necessary libraries installed and if you have enough free space in your working directory.";
|
||||
case RENDERER_KILLED:
|
||||
return "The renderer stopped because either you asked to stop or the server did (usually for a render time too high).";
|
||||
case RENDERER_KILLED_BY_USER:
|
||||
return "The renderer stopped because you've blocked its project.";
|
||||
case SESSION_DISABLED:
|
||||
return "The server has disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc).";
|
||||
case RENDERER_NOT_AVAILABLE:
|
||||
|
||||
@@ -60,6 +60,7 @@ public class Job {
|
||||
private boolean synchronousUpload;
|
||||
private RenderProcess render;
|
||||
private boolean askForRendererKill;
|
||||
private boolean userBlockJob;
|
||||
private Gui gui;
|
||||
private Configuration config;
|
||||
private Log log;
|
||||
@@ -81,6 +82,7 @@ public class Job {
|
||||
script = script_;
|
||||
updateRenderingStatusMethod = update_method_;
|
||||
askForRendererKill = false;
|
||||
userBlockJob = false;
|
||||
log = log_;
|
||||
render = new RenderProcess();
|
||||
}
|
||||
@@ -133,6 +135,14 @@ public class Job {
|
||||
return askForRendererKill;
|
||||
}
|
||||
|
||||
public void setUserBlockJob(boolean val) {
|
||||
userBlockJob = val;
|
||||
}
|
||||
|
||||
public boolean getUserBlockJob() {
|
||||
return userBlockJob;
|
||||
}
|
||||
|
||||
public String getRenderCommand() {
|
||||
return rendererCommand;
|
||||
}
|
||||
@@ -328,6 +338,9 @@ public class Job {
|
||||
|
||||
if (getAskForRendererKill()) {
|
||||
log.debug("Client::runRenderer renderer didn't generate any frame but died due to a kill request");
|
||||
if (getUserBlockJob()) {
|
||||
return Error.Type.RENDERER_KILLED_BY_USER;
|
||||
}
|
||||
return Error.Type.RENDERER_KILLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Server;
|
||||
import com.sheepit.client.os.OS;
|
||||
import com.sheepit.client.standalone.GuiSwing;
|
||||
import com.sheepit.client.standalone.GuiSwing.ActivityType;
|
||||
|
||||
@@ -134,6 +135,12 @@ public class Working implements Activity {
|
||||
parent.getContentPane().add(pauseButton, constraints);
|
||||
|
||||
++currentRow;
|
||||
JButton blockJob = new JButton("Block this project");
|
||||
constraints.gridx = 1;
|
||||
constraints.gridy = currentRow;
|
||||
blockJob.addActionListener(new blockJobAction());
|
||||
parent.getContentPane().add(blockJob, constraints);
|
||||
|
||||
exitAfterFrame = new JButton("Exit after this frame");
|
||||
constraints.gridx = 2;
|
||||
constraints.gridy = currentRow;
|
||||
@@ -238,4 +245,16 @@ public class Working implements Activity {
|
||||
}
|
||||
}
|
||||
|
||||
class blockJobAction implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Client client = parent.getClient();
|
||||
if (client != null) {
|
||||
client.getRenderingJob().setAskForRendererKill(true);
|
||||
client.getRenderingJob().setUserBlockJob(true);
|
||||
OS.getOS().kill(client.getRenderingJob().getProcessRender().getProcess());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user