Skip to content

Commit 57bee97

Browse files
committedFeb 17, 2014
Local (user installed) libraries have priority over system libraries
See #1853
1 parent 1d060ca commit 57bee97

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed
 

‎app/src/processing/app/Base.java

+23-13
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ public void actionPerformed(ActionEvent event) {
12111211
boolean ifound = false;
12121212

12131213
for (String potentialName : list) {
1214-
File subfolder = new File(folder, potentialName);
1214+
File libFolder = new File(folder, potentialName);
12151215
// File libraryFolder = new File(subfolder, "library");
12161216
// File libraryJar = new File(libraryFolder, potentialName + ".jar");
12171217
// // If a .jar file of the same prefix as the folder exists
@@ -1240,27 +1240,37 @@ public void actionPerformed(ActionEvent event) {
12401240
// // need to associate each import with a library folder
12411241
// String packages[] =
12421242
// Compiler.packageListFromClassPath(libraryClassPath);
1243-
libraries.add(subfolder);
1243+
libraries.add(libFolder);
1244+
String libFolderPath = libFolder.getAbsolutePath();
12441245
try {
1245-
String packages[] =
1246-
Compiler.headerListFromIncludePath(subfolder.getAbsolutePath());
1247-
for (String pkg : packages) {
1248-
File old = importToLibraryTable.get(pkg);
1246+
String headers[] = Compiler.headerListFromIncludePath(libFolderPath);
1247+
for (String header : headers) {
1248+
// Extract file name (without extension ".h")
1249+
String name = header.substring(0, header.length() - 2);
1250+
1251+
// If the header name equals to the current library folder use it
1252+
if (libFolderPath.endsWith(name)) {
1253+
importToLibraryTable.put(header, libFolder);
1254+
continue;
1255+
}
1256+
1257+
// If a library was already found with this header, keep it if
1258+
// the library's directory name matches the header name.
1259+
File old = importToLibraryTable.get(header);
12491260
if (old != null) {
1250-
// If a library was already found with this header, keep it if
1251-
// the library's directory name matches the header name.
1252-
String name = pkg.substring(0, pkg.length() - 2);
1253-
if (old.getPath().endsWith(name)) continue;
1261+
if (old.getPath().endsWith(name))
1262+
continue;
12541263
}
1255-
importToLibraryTable.put(pkg, subfolder);
1264+
importToLibraryTable.put(header, libFolder);
12561265
}
12571266
} catch (IOException e) {
1258-
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", subfolder), e);
1267+
showWarning(_("Error"), I18n.format(
1268+
"Unable to list header files in {0}", libFolder), e);
12591269
}
12601270

12611271
JMenuItem item = new JMenuItem(libraryName);
12621272
item.addActionListener(listener);
1263-
item.setActionCommand(subfolder.getAbsolutePath());
1273+
item.setActionCommand(libFolderPath);
12641274
menu.add(item);
12651275
ifound = true;
12661276

0 commit comments

Comments
 (0)
Please sign in to comment.