Fix int field paste breaking it

This commit is contained in:
crschnick 2023-08-20 01:43:27 +00:00
parent f736ce1a7a
commit a80c22f34c
3 changed files with 27 additions and 1 deletions

View file

@ -1,9 +1,12 @@
package io.xpipe.app.core; package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.OsType;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
public class AppChecks { public class AppChecks {
@ -26,4 +29,26 @@ public class AppChecks {
.handle(); .handle();
} }
} }
private static void checkTemp(String tmpdir) {
Path dir = null;
try {
dir = Path.of(tmpdir);
} catch (InvalidPathException ignored) {
}
if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir) || !Files.isWritable(dir)) {
ErrorEvent.fromThrowable(
new IOException("Specified temporary directory " + tmpdir + ", set via the environment variable %TEMP% is invalid."))
.term()
.handle();
}
}
public static void checkTemp() {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
checkTemp(System.getProperty("java.io.tmpdir"));
checkTemp(System.getenv("TEMP"));
}
}
} }

View file

@ -89,6 +89,7 @@ public abstract class OperationMode {
AppState.init(); AppState.init();
XPipeSession.init(AppProperties.get().getBuildUuid()); XPipeSession.init(AppProperties.get().getBuildUuid());
AppChecks.checkDirectoryPermissions(); AppChecks.checkDirectoryPermissions();
AppChecks.checkTemp();
AppLogs.init(); AppLogs.init();
AppProperties.logArguments(args); AppProperties.logArguments(args);
AppProperties.logSystemProperties(); AppProperties.logSystemProperties();

View file

@ -67,7 +67,7 @@ public class IntFieldComp extends Comp<CompStructure<TextField>> {
}); });
text.textProperty().addListener((observableValue, oldValue, newValue) -> { text.textProperty().addListener((observableValue, oldValue, newValue) -> {
if (newValue == null || "".equals(newValue) || (minValue < 0 && "-".equals(newValue))) { if (newValue == null || newValue.isEmpty() || (minValue < 0 && "-".equals(newValue)) || !newValue.matches("-?\\d+")) {
value.setValue(null); value.setValue(null);
return; return;
} }