v0.9.2: added various safety checks to reduce the chance of crashes
This commit is contained in:
parent
3afc33d48d
commit
778fafbcdd
|
@ -532,24 +532,10 @@ public class GameScene extends PixelScene {
|
|||
public void destroy() {
|
||||
|
||||
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
||||
if (actorThread != null && actorThread.isAlive()){
|
||||
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();
|
||||
t.setStackTrace(actorThread.getStackTrace());
|
||||
throw new RuntimeException("timeout waiting for actor thread! ", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!waitForActorThread( 4500 )){
|
||||
Throwable t = new Throwable();
|
||||
t.setStackTrace(actorThread.getStackTrace());
|
||||
throw new RuntimeException("timeout waiting for actor thread! ", t);
|
||||
}
|
||||
|
||||
Emitter.freezeEmitters = false;
|
||||
|
@ -567,10 +553,28 @@ public class GameScene extends PixelScene {
|
|||
actorThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
public synchronized void onPause() {
|
||||
try {
|
||||
waitForActorThread(500);
|
||||
Dungeon.saveAll();
|
||||
Badges.saveGlobal();
|
||||
Journal.saveGlobal();
|
||||
|
|
|
@ -50,13 +50,15 @@ public class AttackIndicator extends Tag {
|
|||
|
||||
public AttackIndicator() {
|
||||
super( DangerIndicator.COLOR );
|
||||
|
||||
instance = this;
|
||||
lastTarget = null;
|
||||
|
||||
setSize( 24, 24 );
|
||||
visible( false );
|
||||
enable( false );
|
||||
|
||||
synchronized (this) {
|
||||
instance = this;
|
||||
lastTarget = null;
|
||||
|
||||
setSize(24, 24);
|
||||
visible(false);
|
||||
enable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user