v0.9.2: added various safety checks to reduce the chance of crashes
This commit is contained in:
parent
3afc33d48d
commit
778fafbcdd
|
@ -532,25 +532,11 @@ public class GameScene extends PixelScene {
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
|
||||||
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
||||||
if (actorThread != null && actorThread.isAlive()){
|
if (!waitForActorThread( 4500 )){
|
||||||
synchronized (GameScene.class){
|
|
||||||
synchronized (actorThread) {
|
|
||||||
actorThread.interrupt();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
GameScene.class.wait(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
ShatteredPixelDungeon.reportException(e);
|
|
||||||
}
|
|
||||||
synchronized (actorThread) {
|
|
||||||
if (Actor.processing()) {
|
|
||||||
Throwable t = new Throwable();
|
Throwable t = new Throwable();
|
||||||
t.setStackTrace(actorThread.getStackTrace());
|
t.setStackTrace(actorThread.getStackTrace());
|
||||||
throw new RuntimeException("timeout waiting for actor thread! ", t);
|
throw new RuntimeException("timeout waiting for actor thread! ", t);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Emitter.freezeEmitters = false;
|
Emitter.freezeEmitters = false;
|
||||||
|
|
||||||
|
@ -568,9 +554,27 @@ public class GameScene extends PixelScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean waitForActorThread(int msToWait ){
|
||||||
|
if (actorThread != null && actorThread.isAlive()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
synchronized (actorThread) {
|
||||||
|
actorThread.interrupt();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
GameScene.class.wait(msToWait);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
ShatteredPixelDungeon.reportException(e);
|
||||||
|
}
|
||||||
|
synchronized (actorThread) {
|
||||||
|
return Actor.processing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onPause() {
|
public synchronized void onPause() {
|
||||||
try {
|
try {
|
||||||
|
waitForActorThread(500);
|
||||||
Dungeon.saveAll();
|
Dungeon.saveAll();
|
||||||
Badges.saveGlobal();
|
Badges.saveGlobal();
|
||||||
Journal.saveGlobal();
|
Journal.saveGlobal();
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class AttackIndicator extends Tag {
|
||||||
public AttackIndicator() {
|
public AttackIndicator() {
|
||||||
super( DangerIndicator.COLOR );
|
super( DangerIndicator.COLOR );
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
instance = this;
|
instance = this;
|
||||||
lastTarget = null;
|
lastTarget = null;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ public class AttackIndicator extends Tag {
|
||||||
visible(false);
|
visible(false);
|
||||||
enable(false);
|
enable(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameAction keyAction() {
|
public GameAction keyAction() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user