Fix potential crash in Video Settings.

When Shaders folder didn't exist it would cause crash.
This commit is contained in:
Ryan Houdek 2014-06-02 17:57:23 -05:00
parent 31eedb2f79
commit 7dc31fbd1a
1 changed files with 13 additions and 8 deletions

View File

@ -63,7 +63,7 @@ public final class VideoSettingsFragment extends PreferenceFragment
// //
// Set available post processing shaders // Set available post processing shaders
// //
File[] shaders = new File(Environment.getExternalStorageDirectory()+ File.separator+"dolphin-emu"+ File.separator+"Shaders").listFiles();
List<CharSequence> shader_names = new ArrayList<CharSequence>(); List<CharSequence> shader_names = new ArrayList<CharSequence>();
List<CharSequence> shader_values = new ArrayList<CharSequence>(); List<CharSequence> shader_values = new ArrayList<CharSequence>();
@ -71,16 +71,21 @@ public final class VideoSettingsFragment extends PreferenceFragment
shader_names.add("Disabled"); shader_names.add("Disabled");
shader_values.add(""); 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 (file.isFile())
if (filename.contains(".glsl"))
{ {
// Strip the extension and put it in to the list String filename = file.getName();
shader_names.add(filename.substring(0, filename.lastIndexOf('.'))); if (filename.contains(".glsl"))
shader_values.add(filename.substring(0, filename.lastIndexOf('.'))); {
// 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('.')));
}
} }
} }
} }