Fix #47 User can block a project on his client

This commit is contained in:
Laurent Clouet
2015-10-27 21:00:44 +00:00
parent 8b25a08f6a
commit 4873b8272b
4 changed files with 36 additions and 1 deletions

View File

@@ -436,7 +436,7 @@ public class Client {
// no exception should be raised to actual launcher (applet or standalone) // 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 // do nothing, we can ask for a job right away
} }
else { else {

View File

@@ -38,6 +38,7 @@ public class Error {
RENDERER_CRASHED(12), RENDERER_CRASHED(12),
RENDERER_OUT_OF_VIDEO_MEMORY(13), RENDERER_OUT_OF_VIDEO_MEMORY(13),
RENDERER_KILLED(14), RENDERER_KILLED(14),
RENDERER_KILLED_BY_USER(20),
RENDERER_MISSING_LIBRARIES(15), RENDERER_MISSING_LIBRARIES(15),
FAILED_TO_EXECUTE(16), FAILED_TO_EXECUTE(16),
OS_NOT_SUPPORTED(17), 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."; 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: case RENDERER_KILLED:
return "The renderer stopped because either you asked to stop or the server did (usually for a render time too high)."; 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: 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)."; 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: case RENDERER_NOT_AVAILABLE:

View File

@@ -60,6 +60,7 @@ public class Job {
private boolean synchronousUpload; private boolean synchronousUpload;
private RenderProcess render; private RenderProcess render;
private boolean askForRendererKill; private boolean askForRendererKill;
private boolean userBlockJob;
private Gui gui; private Gui gui;
private Configuration config; private Configuration config;
private Log log; private Log log;
@@ -81,6 +82,7 @@ public class Job {
script = script_; script = script_;
updateRenderingStatusMethod = update_method_; updateRenderingStatusMethod = update_method_;
askForRendererKill = false; askForRendererKill = false;
userBlockJob = false;
log = log_; log = log_;
render = new RenderProcess(); render = new RenderProcess();
} }
@@ -133,6 +135,14 @@ public class Job {
return askForRendererKill; return askForRendererKill;
} }
public void setUserBlockJob(boolean val) {
userBlockJob = val;
}
public boolean getUserBlockJob() {
return userBlockJob;
}
public String getRenderCommand() { public String getRenderCommand() {
return rendererCommand; return rendererCommand;
} }
@@ -328,6 +338,9 @@ public class Job {
if (getAskForRendererKill()) { if (getAskForRendererKill()) {
log.debug("Client::runRenderer renderer didn't generate any frame but died due to a kill request"); 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; return Error.Type.RENDERER_KILLED;
} }

View File

@@ -16,6 +16,7 @@ import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import com.sheepit.client.Client; import com.sheepit.client.Client;
import com.sheepit.client.Server; import com.sheepit.client.Server;
import com.sheepit.client.os.OS;
import com.sheepit.client.standalone.GuiSwing; import com.sheepit.client.standalone.GuiSwing;
import com.sheepit.client.standalone.GuiSwing.ActivityType; import com.sheepit.client.standalone.GuiSwing.ActivityType;
@@ -134,6 +135,12 @@ public class Working implements Activity {
parent.getContentPane().add(pauseButton, constraints); parent.getContentPane().add(pauseButton, constraints);
++currentRow; ++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"); exitAfterFrame = new JButton("Exit after this frame");
constraints.gridx = 2; constraints.gridx = 2;
constraints.gridy = currentRow; 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());
}
}
}
} }