From efc28455c1c7dbd8f843c339ebd4854e59cc2001 Mon Sep 17 00:00:00 2001 From: localhorst Date: Sun, 9 Jun 2019 13:29:07 +0200 Subject: [PATCH] fixed error handling at import --- .../org/hso/texturesyncclient/controller/RootController.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt index 16fb1d1..32be17d 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt @@ -49,11 +49,11 @@ class RootController : Controller() { * @param tags all tags for the file */ fun importTexture(path: String, name: String, tags: ObservableList) { - var data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array + val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array val uuid = UUID.randomUUID() val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG - val bimg = ImageIO.read(File(path)) //image for obtaining resolution + var bimg = ImageIO.read(File(path)) //image for obtaining resolution val resolution = Pair(bimg.height, bimg.width) val cal = Calendar.getInstance() //calendar obj with current time val hash = Sha256(data) @@ -73,7 +73,6 @@ class RootController : Controller() { "-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;" ) - data = null //Free image val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash) @@ -85,7 +84,9 @@ class RootController : Controller() { alertImportHash.showAndWait() } catch (e: Exception) { alertImport.showAndWait() + println(e) } + } /**