Skip to content

Commit ed0d1b4

Browse files
author
schlimme-gegend
committed
Successfully shutting down animation threads.
1 parent 765a4dd commit ed0d1b4

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

core/src/processing/android/PWallpaper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import android.graphics.Point;
3333
import android.graphics.Rect;
3434

35+
3536
public class PWallpaper extends WallpaperService implements AppComponent {
3637
private Point size;
3738
private DisplayMetrics metrics;
@@ -209,7 +210,7 @@ public void onSurfaceDestroyed(SurfaceHolder holder) {
209210
// surface. If you have a rendering thread that directly accesses the
210211
// surface, you must ensure that thread is no longer touching the Surface
211212
// before returning from this function.
212-
super.onSurfaceDestroyed(holder);
213+
super.onSurfaceDestroyed(holder);
213214
}
214215

215216

core/src/processing/core/PSurfaceNone.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public boolean stopThread() {
434434
if (thread == null) {
435435
return false;
436436
}
437-
thread = null;
437+
thread.interrupt();
438438
return true;
439439
}
440440

@@ -451,15 +451,11 @@ public void setFrameRate(float fps) {
451451
}
452452

453453

454-
protected void checkPause() {
454+
protected void checkPause() throws InterruptedException {
455455
// if (paused) {
456456
synchronized (pauseObject) {
457457
while (paused) {
458-
try {
459-
pauseObject.wait();
460-
} catch (InterruptedException e) {
461-
// waiting for this interrupt on a start() (resume) call
462-
}
458+
pauseObject.wait();
463459
}
464460
}
465461
}
@@ -499,7 +495,17 @@ public void run() { // not good to make this synchronized, locks things up
499495

500496
while ((Thread.currentThread() == thread) &&
501497
(sketch != null && !sketch.finished)) {
502-
checkPause();
498+
if (Thread.currentThread().isInterrupted()) {
499+
finish();
500+
return;
501+
}
502+
try {
503+
checkPause();
504+
} catch (InterruptedException e) {
505+
finish();
506+
return;
507+
}
508+
503509
callDraw();
504510

505511
// wait for update & paint to happen before drawing next frame

0 commit comments

Comments
 (0)