v0.4.3a: fixed several issues revealed by new bundle error reporting
This commit is contained in:
parent
ac3439d0e5
commit
22c1a0189c
|
@ -29,6 +29,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
@ -118,7 +119,7 @@ public class Bundle {
|
|||
}
|
||||
|
||||
Class<?> cl = Class.forName( clName );
|
||||
if (cl != null) {
|
||||
if (cl != null && (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers()))) {
|
||||
Bundlable object = (Bundlable)cl.newInstance();
|
||||
object.restoreFromBundle( this );
|
||||
return object;
|
||||
|
@ -367,11 +368,16 @@ public class Bundle {
|
|||
public void put( String key, Collection<? extends Bundlable> collection ) {
|
||||
JSONArray array = new JSONArray();
|
||||
for (Bundlable object : collection) {
|
||||
//Skip none-static inner classes as they can't be instantiated through bundle restoring
|
||||
//Classes which make use of none-static inner classes must manage instantiation manually
|
||||
if (object != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.put(CLASS_NAME, object.getClass().getName());
|
||||
object.storeInBundle(bundle);
|
||||
array.put(bundle.data);
|
||||
Class cl = object.getClass();
|
||||
if (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers())) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.put(CLASS_NAME, cl.getName());
|
||||
object.storeInBundle(bundle);
|
||||
array.put(bundle.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -88,21 +88,23 @@ public class Blob extends Actor {
|
|||
|
||||
super.restoreFromBundle( bundle );
|
||||
|
||||
if (bundle.contains(LENGTH)) {
|
||||
cur = new int[bundle.getInt(LENGTH)];
|
||||
} else {
|
||||
//compatability with pre-0.4.2
|
||||
cur = new int[1024];
|
||||
}
|
||||
off = new int[cur.length];
|
||||
|
||||
int[] data = bundle.getIntArray( CUR );
|
||||
if (data != null) {
|
||||
int start = bundle.getInt( START );
|
||||
for (int i=0; i < data.length; i++) {
|
||||
if (bundle.contains( CUR )) {
|
||||
|
||||
if (bundle.contains(LENGTH)) {
|
||||
cur = new int[bundle.getInt(LENGTH)];
|
||||
} else {
|
||||
//compatability with pre-0.4.2
|
||||
cur = new int[1024];
|
||||
}
|
||||
off = new int[cur.length];
|
||||
|
||||
int[] data = bundle.getIntArray(CUR);
|
||||
int start = bundle.getInt(START);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
cur[i + start] = data[i];
|
||||
volume += data[i];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user