mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fixed empty transform vector if failed to load settings
Former-commit-id: 52079c03c3c4e87160ea4e077edbadc9900e6e20
This commit is contained in:
parent
30c75263c0
commit
f2253f185f
@ -1 +1 @@
|
||||
f952d16d70fad0d6063d719588a5cf7c05d9c257
|
||||
bfe21c488f982bc107e7acaa4c90be41a6782f9e
|
@ -12,6 +12,8 @@ import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* Class for supporting the serialisation and deserialisation of HyperCon settings.
|
||||
@ -29,8 +31,8 @@ public class ConfigurationFile {
|
||||
public void load(String pFilename) {
|
||||
mProps.clear();
|
||||
// try (InputStream in = new InflaterInputStream(new FileInputStream(pFilename))){
|
||||
// try (InputStream in = new GZIPInputStream(new FileInputStream(pFilename))){
|
||||
try (InputStream in = new FileInputStream(pFilename)) {
|
||||
try (InputStream in = new GZIPInputStream(new FileInputStream(pFilename))){
|
||||
// try (InputStream in = new FileInputStream(pFilename)) {
|
||||
mProps.load(in);
|
||||
} catch (Throwable t) {
|
||||
// TODO Auto-generated catch block
|
||||
@ -45,8 +47,8 @@ public class ConfigurationFile {
|
||||
*/
|
||||
public void save(String pFilename) {
|
||||
// try (OutputStream out = new DeflaterOutputStream(new FileOutputStream(pFilename))) {
|
||||
// try (OutputStream out = new GZIPOutputStream(new FileOutputStream(pFilename))) {
|
||||
try (OutputStream out = (new FileOutputStream(pFilename))) {
|
||||
try (OutputStream out = new GZIPOutputStream(new FileOutputStream(pFilename))) {
|
||||
// try (OutputStream out = (new FileOutputStream(pFilename))) {
|
||||
mProps.store(out, "Pesistent settings file for HyperCon");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -9,6 +9,7 @@ import javax.swing.JFrame;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.hyperion.hypercon.gui.ConfigPanel;
|
||||
import org.hyperion.hypercon.spec.TransformConfig;
|
||||
|
||||
/**
|
||||
* (static) Main-class for starting HyperCon (the Hyperion configuration file builder) as a standard
|
||||
@ -44,6 +45,7 @@ public class Main {
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
try {
|
||||
ConfigurationFile configFile = new ConfigurationFile();
|
||||
configFile.store(Main.HyperConConfig);
|
||||
configFile.store(ledString.mDeviceConfig);
|
||||
@ -52,10 +54,14 @@ public class Main {
|
||||
configFile.store(ledString.mColorConfig);
|
||||
configFile.store(ledString.mMiscConfig);
|
||||
configFile.save(configFilename);
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Failed to save " + configFilename);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (new File(configFilename).exists()) {
|
||||
try {
|
||||
ConfigurationFile configFile = new ConfigurationFile();
|
||||
configFile.load(configFilename);
|
||||
configFile.restore(Main.HyperConConfig);
|
||||
@ -64,6 +70,12 @@ public class Main {
|
||||
configFile.restore(ledString.mProcessConfig);
|
||||
configFile.restore(ledString.mColorConfig);
|
||||
configFile.restore(ledString.mMiscConfig);
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Failed to load " + configFilename);
|
||||
}
|
||||
if (ledString.mColorConfig.mTransforms.isEmpty()) {
|
||||
ledString.mColorConfig.mTransforms.add(new TransformConfig());
|
||||
}
|
||||
}
|
||||
|
||||
// Add the HyperCon configuration panel
|
||||
|
Loading…
Reference in New Issue
Block a user