raeleus / skin-composer

Create skins for LibGDX scene2d.ui with a graphical interface.
MIT License
429 stars 35 forks source link

Unable to open a skin after saving it #81

Closed IchZerowan closed 4 years ago

IchZerowan commented 4 years ago

When trying to open a saved .scmp file I get an error: com.badlogic.gdx.utils.SerializationException: Class cannot be created (missing no-arg constructor): com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle Serialization trace: file (com.ray3k.skincomposer.data.DrawableData) at com.badlogic.gdx.utils.Json.newInstance(Json.java:1221) at com.badlogic.gdx.utils.Json.readValue(Json.java:1009) at com.badlogic.gdx.utils.Json.readFields(Json.java:902) at com.badlogic.gdx.utils.Json.readValue(Json.java:1074) at com.badlogic.gdx.utils.Json.readValue(Json.java:1097) at com.badlogic.gdx.utils.Json.readValue(Json.java:945) at com.ray3k.skincomposer.data.AtlasData.read(AtlasData.java:289) at com.badlogic.gdx.utils.Json.readValue(Json.java:1012) at com.badlogic.gdx.utils.Json.readValue(Json.java:930) at com.ray3k.skincomposer.data.ProjectData.read(ProjectData.java:616) at com.badlogic.gdx.utils.Json.readValue(Json.java:1012) at com.badlogic.gdx.utils.Json.fromJson(Json.java:769) at com.ray3k.skincomposer.data.ProjectData.load(ProjectData.java:404) at com.ray3k.skincomposer.MainListener.lambda$openFile$3(MainListener.java:326) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:154) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:114) at com.ray3k.skincomposer.desktop.DesktopLauncher.main(DesktopLauncher.java:404) Caused by: com.badlogic.gdx.utils.reflect.ReflectionException: Could not instantiate instance of class: com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:95) at com.badlogic.gdx.utils.Json.newInstance(Json.java:1203) ... 16 more Caused by: java.lang.InstantiationException: com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle at java.base/java.lang.Class.newInstance(Unknown Source) at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:93) ... 17 more Caused by: java.lang.NoSuchMethodException: com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle.<init>() at java.base/java.lang.Class.getConstructor0(Unknown Source) ... 19 more

raeleus commented 4 years ago

Yeah, this is an odd one reported by other folks too. I'll find a solution when I can. Sorry for the inconvenience.

raeleus commented 4 years ago

Oh, i forgot to mention. Using the JAR release should avoid the issue.

IchZerowan commented 4 years ago

Oh, i forgot to mention. Using the JAR release should avoid the issue.

Didn't help, unfortunately. How can I help to resolve this? Probably, you need the skin sources to reproduce the issue?

IchZerowan commented 4 years ago

The trouble is with project file deserialization, I tried to figure out what happens but ain't currently good enough in LibGDX API so didn't get how object deserialization should work. I don't see the default constructor for com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle in LibGDX sources.

raeleus commented 4 years ago

About the JAR release: if you make a new skin with the jar version, it shouldn't corrupt the file when it saves it. If you look into the SCMP file with a text editor, you should see that some instances serialized as Lwjgl3FileHandle instead of FileHandle. I have no idea why it would do that, but I know of a workaround. Just need the time to focus on Skin Composer. I promise, it's the next thing on my list.

IchZerowan commented 4 years ago

Probably I am doing something wrong but saving a new skin with jar version behaves just the same, and the SCMP file also contains Lwjgl3FileHandle references. Just replacing the class name in SCMP file didn't help. Thanks for your effort investigating the issue. Looking forward to have a fix :)

raeleus commented 4 years ago

Ouch! Okay that is bad, but helps me understand thw problem better. The FileHandle package is completely different than the LWJGL3 one, but I wouldn't bother if it's just going to fuck it up again.

IchZerowan commented 4 years ago

By "changing" the class name I meant changing the class name AND the package name

raeleus commented 4 years ago

Oh okay, sorry. Yeah, probably forgetting what else needs to be changed. Working off of memory alone is hard. šŸ˜­