pull/99/head
Mattia Iavarone 8 years ago
parent 7035b915a0
commit 4f5ced72e2
  1. 12
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java

@ -84,6 +84,13 @@ abstract class CameraController implements
//region Error handling //region Error handling
private static class NoOpExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
// No-op.
}
}
@Override @Override
public void uncaughtException(final Thread thread, final Throwable throwable) { public void uncaughtException(final Thread thread, final Throwable throwable) {
// Something went wrong. Thread is terminated (about to?). // Something went wrong. Thread is terminated (about to?).
@ -126,8 +133,9 @@ abstract class CameraController implements
final void destroy() { final void destroy() {
LOG.i("destroy:", "state:", ss()); LOG.i("destroy:", "state:", ss());
// Prevent CameraController leaks. // Prevent CameraController leaks. Don't set to null, or exceptions
mHandler.getThread().setUncaughtExceptionHandler(null); // inside the standard stop() method might crash the main thread.
mHandler.getThread().setUncaughtExceptionHandler(new NoOpExceptionHandler());
// Stop if needed. // Stop if needed.
stopImmediately(); stopImmediately();
} }

Loading…
Cancel
Save