raeleus/skin-composer

NPE on project loading

doriancransac opened this issue · 2 comments

Hi,

I keep getting the following NPE when loading my project even though it saved properly and the resulting export works in libgdx.

java.lang.NullPointerException
	at com.ray3k.skincomposer.data.ProjectData.correctFilePaths(ProjectData.java:563)
	at com.ray3k.skincomposer.data.ProjectData.load(ProjectData.java:441)
	at com.ray3k.skincomposer.MainListener.lambda$openFile$3(MainListener.java:312)
	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:406)

I was able to figure out that the problem correlates to the presence of PIXEL objects in the json file, which I create & use as part of the "cursor" and "selection" properties of my TextField:

image

resulting in the following data inside the json file:


{
			file: null
			bgColor: {
				r: 0
				g: 0
				b: 0
				a: 1
			}
			tint: null
			tintName: pale
			name: palePixel
			tiled: false
			minWidth: -1
			minHeight: -1
			customized: false
			tenPatchData: null
			type: PIXEL
			hidden: false
		}
		{
			file: null
			bgColor: {
				r: 1
				g: 1
				b: 1
				a: 1
			}
			tint: null
			tintName: dirt
			name: redPixel
			tiled: false
			minWidth: -1
			minHeight: -1
			customized: false
			tenPatchData: null
			type: PIXEL
			hidden: false
		}

[...]


                                        cursor: {
						type: com.badlogic.gdx.scenes.scene2d.utils.Drawable
						name: cursor
						optional: true
						value: palePixel
					}
					selection: {
						type: com.badlogic.gdx.scenes.scene2d.utils.Drawable
						name: selection
						optional: true
						value: redPixel
					}

However, I was not able to reproduce the problem in "isolation" in a new project, so there must be something else from my project that's involved in it or conflicts with these PIXEL objects. I'm not seeing any differences in these json blocks between the clean "fresh" project and the corrupt project. I initially thought the problem was related to the "file: null" line but it does make sense that a PIXEL object doesn't point to a file or folder, so I have no idea what's going on with the correctFilePaths(ProjectData.java:563) method & line.

All I know is that when I remove the PIXEL object blocks from the json, the project opens again but I have to recreate them and reexport every time I close the project which is a pain.

Any idea what's going on here?

It appears to be an issue when the project is saved with Keep Resources Relative and Pixel drawables. To reproduce, you have to have at least one other kind of Drawable included in the project. This will be resolved with the next version.

Sweet, thanks for the update!