Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE after deleting a MatParam 2x #6

Closed
stephengold opened this issue Sep 7, 2021 · 7 comments
Closed

NPE after deleting a MatParam 2x #6

stephengold opened this issue Sep 7, 2021 · 7 comments

Comments

@stephengold
Copy link
Owner

At commit: 4cd137d
To reproduce: 6, 1, Select geometry, 1, Select parameter, 1, Delete, Z, Delete
Expected: darker model with fewer material parameters
Got:


Sep 07, 2021 9:22:55 AM jme3utilities.nifty.BasicScreenController perform
SEVERE: Caught unexpected throwable:
java.lang.NullPointerException
	at maud.model.cgm.MatParamRef.<init>(MatParamRef.java:90)
	at maud.model.cgm.SelectedMatParam.makeRef(SelectedMatParam.java:230)
	at maud.model.cgm.SelectedMatParam.delete(SelectedMatParam.java:78)
	at maud.action.DeleteAction.process(DeleteAction.java:92)

Hypothesis: cloning bug in Material or MatParam

Note that after the undo, the parameter type and value are both displayed as "null"! They should be "Vector4" and "Color[0.7058824, 0.6509804, 0.6, 1.0]" respectively.

@stephengold
Copy link
Owner Author

After the undo, getMatParam().findNameIndex() [which uses material.getParams()] returns a negative value, yet getMatParam().isSelected() [which looks only at selectedName] returns true.

@stephengold
Copy link
Owner Author

stephengold commented Sep 7, 2021

The paramValues map in Material has only 8 entries and does not contain one for "Ambient". Material is Cloneable but not JmeCloneable. Material.clone() is invoked during the MP delete (both for Jaime and SkyControl) and appears to clone paramValues correctly.

@stephengold
Copy link
Owner Author

Note that History.undo() invokes Cgm.clone() 4x: cloning source and target for both new Checkpoint and previous.restore(). The issue is presumably during restore() of the target.

@stephengold
Copy link
Owner Author

When the first checkpoint is created, it reports the VarType as Vector4. The same checkpoint is later restored, but at that time it reports the VarType as null. In fact, it's the same SelectedMatParam instance and the same Material instance from when the checkpoint was created. Looks like the Material got aliased somewhere.

@stephengold
Copy link
Owner Author

Geometry.cloneFields() sure looks like it clones the material field...

@stephengold
Copy link
Owner Author

Looks like Cgm.clone() fails to update a few backpointers. This might be an easy fix!

@stephengold
Copy link
Owner Author

stephengold commented Sep 7, 2021

Fixed in "master" at 5aff82e

Well, that kept me entertained for a few hours...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant