Fix: NPE that occurs when the config file specifies a GPU thats not available anymore

This commit is contained in:
harlekin
2021-02-23 20:25:56 +00:00
committed by Sheepit Renderfarm
parent c0155f141b
commit e5b102b2d7
2 changed files with 12 additions and 1 deletions

View File

@@ -35,6 +35,9 @@ import java.util.Set;
import com.sheepit.client.Configuration.ComputeType;
import com.sheepit.client.hardware.gpu.GPU;
import com.sheepit.client.hardware.gpu.GPUDevice;
import com.sheepit.client.standalone.GuiSwing;
import com.sheepit.client.standalone.GuiText;
import com.sheepit.client.standalone.GuiTextOneLine;
import lombok.Setter;
public class SettingsLoader {
@@ -399,6 +402,10 @@ public class SettingsLoader {
// And now update the client configuration with the new value
config.setRenderbucketSize(config.getGPUDevice().getRenderbucketSize());
}
else if (config.getUIType() != null && (config.getUIType().equals(GuiText.type) || config.getUIType().equals(GuiTextOneLine.type))) {
System.err.println("SettingsLoader::merge could not find specified GPU");
System.exit(2);
}
}
else if (config.getGPUDevice() != null) {
// The order of conditions is important to ensure the priority or app arguments, then the config file and finally the recommended size (if none

View File

@@ -71,6 +71,8 @@ import com.sheepit.client.hardware.gpu.opencl.OpenCL;
import com.sheepit.client.network.Proxy;
import com.sheepit.client.os.OS;
import com.sheepit.client.standalone.GuiSwing;
import com.sheepit.client.standalone.GuiText;
import com.sheepit.client.standalone.GuiTextOneLine;
import com.sheepit.client.standalone.swing.components.CollapsibleJPanel;
public class Settings implements Activity {
@@ -316,7 +318,9 @@ public class Settings implements Activity {
int maxRenderbucketSize = 128;
int recommendedBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
if (config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) {
//When replacing gpus it can happen that the client can't find the one specified in the config anymore in which case config.getGPUDevice()
//returns null
if ((config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) && config.getGPUDevice() != null) {
GPULister gpu;
if (config.getGPUDevice().getType().equals("CUDA")) {