From 7dc31fbd1a1c4f4a0015520fdbc693bdb66a5fed Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 2 Jun 2014 17:57:23 -0500 Subject: [PATCH] Fix potential crash in Video Settings. When Shaders folder didn't exist it would cause crash. --- .../settings/video/VideoSettingsFragment.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java index e0ba5d3754..fe41335bd3 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java @@ -63,7 +63,7 @@ public final class VideoSettingsFragment extends PreferenceFragment // // Set available post processing shaders // - File[] shaders = new File(Environment.getExternalStorageDirectory()+ File.separator+"dolphin-emu"+ File.separator+"Shaders").listFiles(); + List shader_names = new ArrayList(); List shader_values = new ArrayList(); @@ -71,16 +71,21 @@ public final class VideoSettingsFragment extends PreferenceFragment shader_names.add("Disabled"); shader_values.add(""); - for (File file : shaders) + File shaders_folder = new File(Environment.getExternalStorageDirectory()+ File.separator+"dolphin-emu"+ File.separator+"Shaders"); + if (shaders_folder.exists()) { - if (file.isFile()) + File[] shaders = shaders_folder.listFiles(); + for (File file : shaders) { - String filename = file.getName(); - if (filename.contains(".glsl")) + if (file.isFile()) { - // Strip the extension and put it in to the list - shader_names.add(filename.substring(0, filename.lastIndexOf('.'))); - shader_values.add(filename.substring(0, filename.lastIndexOf('.'))); + String filename = file.getName(); + if (filename.contains(".glsl")) + { + // Strip the extension and put it in to the list + shader_names.add(filename.substring(0, filename.lastIndexOf('.'))); + shader_values.add(filename.substring(0, filename.lastIndexOf('.'))); + } } } }