From a93ffc7d98845dedaf5a20faf47d6807454b1a17 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 10 Oct 2011 18:17:43 +0000 Subject: [PATCH] Handling situation when resolutions array is null. --- .../video/src/processing/video/Capture.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/java/libraries/video/src/processing/video/Capture.java b/java/libraries/video/src/processing/video/Capture.java index 330694669..69ec09f11 100644 --- a/java/libraries/video/src/processing/video/Capture.java +++ b/java/libraries/video/src/processing/video/Capture.java @@ -473,11 +473,18 @@ public class Capture extends PImage implements PConstants { * @return Resolution[] */ public Resolution[] resolutions() { - int n = resolutions.size(); - Resolution[] res = new Resolution[n]; - for (int i = 0; i < n; i++) { - res[i] = new Resolution((Resolution)resolutions.get(i)); + Resolution[] res; + + if (resolutions == null) { + res = new Resolution[0]; + } else { + int n = resolutions.size(); + res = new Resolution[n]; + for (int i = 0; i < n; i++) { + res[i] = new Resolution((Resolution)resolutions.get(i)); + } } + return res; }