mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Permissions/IO errors can cause nullpointerexception
Fixes #1160 Merge remote-tracking branch 'arduino/ide-1.5.x-issue1160' into ide-1.5.x
This commit is contained in:
commit
a05c73bf8f
@ -1197,9 +1197,14 @@ public class Base {
|
|||||||
// Populate importToLibraryTable
|
// Populate importToLibraryTable
|
||||||
importToLibraryTable = new HashMap<String, File>();
|
importToLibraryTable = new HashMap<String, File>();
|
||||||
for (File subfolder : libraries.values()) {
|
for (File subfolder : libraries.values()) {
|
||||||
String packages[] = headerListFromIncludePath(subfolder);
|
try {
|
||||||
for (String pkg : packages)
|
String packages[] = headerListFromIncludePath(subfolder);
|
||||||
importToLibraryTable.put(pkg, subfolder);
|
for (String pkg : packages) {
|
||||||
|
importToLibraryTable.put(pkg, subfolder);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", subfolder), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update editors status bar
|
// Update editors status bar
|
||||||
@ -1548,8 +1553,13 @@ public class Base {
|
|||||||
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
|
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
ActionListener listener = new ActionListener() {
|
ActionListener listener = new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
activeEditor.getSketch().importLibrary(e.getActionCommand());
|
String jarPath = event.getActionCommand();
|
||||||
|
try {
|
||||||
|
activeEditor.getSketch().importLibrary(jarPath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", jarPath), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1571,8 +1581,12 @@ public class Base {
|
|||||||
* the header files in its sub-folders, as those should be included from
|
* the header files in its sub-folders, as those should be included from
|
||||||
* within the header files at the top-level).
|
* within the header files at the top-level).
|
||||||
*/
|
*/
|
||||||
static public String[] headerListFromIncludePath(File path) {
|
static public String[] headerListFromIncludePath(File path) throws IOException {
|
||||||
return path.list(new OnlyFilesWithExtension(".h"));
|
String[] list = path.list(new OnlyFilesWithExtension(".h"));
|
||||||
|
if (list == null) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadHardware(File folder) {
|
protected void loadHardware(File folder) {
|
||||||
|
@ -1124,7 +1124,7 @@ public class Sketch {
|
|||||||
* Add import statements to the current tab for all of packages inside
|
* Add import statements to the current tab for all of packages inside
|
||||||
* the specified jar file.
|
* the specified jar file.
|
||||||
*/
|
*/
|
||||||
public void importLibrary(String jarPath) {
|
public void importLibrary(String jarPath) throws IOException {
|
||||||
// make sure the user didn't hide the sketch folder
|
// make sure the user didn't hide the sketch folder
|
||||||
ensureExistence();
|
ensureExistence();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user