Defensive change against late callbacks; not clear it's actually any issue

git-svn-id: https://zxing.googlecode.com/svn/trunk@2303 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-06-06 16:34:16 +00:00
parent 4f1c884797
commit 235a12ac42
2 changed files with 9 additions and 1 deletions

View file

@ -735,6 +735,10 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
if (surfaceHolder == null) { if (surfaceHolder == null) {
throw new IllegalStateException("No SurfaceHolder provided"); throw new IllegalStateException("No SurfaceHolder provided");
} }
if (cameraManager.isOpen()) {
Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?");
return;
}
try { try {
cameraManager.openDriver(surfaceHolder); cameraManager.openDriver(surfaceHolder);
// Creating the handler starts the preview, which can also throw a RuntimeException. // Creating the handler starts the preview, which can also throw a RuntimeException.

View file

@ -94,6 +94,10 @@ public final class CameraManager {
configManager.setDesiredCameraParameters(theCamera); configManager.setDesiredCameraParameters(theCamera);
} }
public synchronized boolean isOpen() {
return camera != null;
}
/** /**
* Closes the camera driver if still in use. * Closes the camera driver if still in use.
*/ */
@ -136,7 +140,7 @@ public final class CameraManager {
} }
/** /**
* Convenience method for {@link com.srowen.bs.android.CaptureActivity} * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
*/ */
public synchronized void setTorch(boolean newSetting) { public synchronized void setTorch(boolean newSetting) {
if (camera != null) { if (camera != null) {