Skip to content

Commit ba88401

Browse files
committed
fix error when installing Mode with no windows open (fixes #445, fixes #446)
1 parent 4d33354 commit ba88401

File tree

4 files changed

+28
-108
lines changed

4 files changed

+28
-108
lines changed

app/src/processing/app/contrib/ContributionManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static void downloadAndInstall(final Base base,
193193
status.setErrorMessage(Language
194194
.interpolate("contrib.errors.download_and_install",
195195
ad.getName()));
196+
downloadProgress.exception.printStackTrace();
196197
}
197198
}
198199
contribZip.delete();

app/src/processing/app/contrib/ContributionType.java

Lines changed: 7 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,6 @@ public String getTitle() {
6363
}
6464

6565

66-
/*
67-
public String getPluralTitle() {
68-
switch (this) {
69-
case LIBRARY:
70-
return "Libraries";
71-
case MODE:
72-
return "Modes";
73-
case TOOL:
74-
return "Tools";
75-
case EXAMPLES:
76-
return "Examples";
77-
}
78-
return null; // should be unreachable
79-
}
80-
*/
81-
82-
83-
// public String getFolderName() {
84-
// return toString();
85-
// /*
86-
// switch (this) {
87-
// case LIBRARY:
88-
// return "libraries";
89-
// case TOOL:
90-
// return "tools";
91-
// case MODE:
92-
// return "modes";
93-
// case EXAMPLES:
94-
// return "examples";
95-
// }
96-
// return null; // should be unreachable
97-
// */
98-
// }
99-
100-
10166
/** Get the name of the properties file for this type of contribution. */
10267
public String getPropertiesName() {
10368
return this + ".properties";
@@ -109,42 +74,11 @@ public File createTempFolder() throws IOException {
10974
}
11075

11176

112-
/*
113-
// removed for 4.0a6, doesn't appear to be in use
114-
public File[] listTempFolders() throws IOException {
115-
File base = getSketchbookFolder();
116-
return base.listFiles(new FileFilter() {
117-
@Override
118-
public boolean accept(File file) {
119-
String name = file.getName();
120-
return (file.isDirectory() &&
121-
name.startsWith(toString()) && name.endsWith("tmp"));
122-
}
123-
});
124-
}
125-
*/
126-
127-
12877
public boolean isTempFolderName(String name) {
12978
return name.startsWith(toString()) && name.endsWith("tmp");
13079
}
13180

13281

133-
// public String getTempPrefix() {
134-
// return toString();
135-
// }
136-
//
137-
//
138-
// public String getTempSuffix() {
139-
// return "tmp";
140-
// }
141-
142-
143-
// public String getPropertiesName() {
144-
// return toString() + ".properties";
145-
// }
146-
147-
14882
static public ContributionType fromName(String s) {
14983
if (s != null) {
15084
if ("library".equalsIgnoreCase(s)) {
@@ -239,20 +173,22 @@ LocalContribution load(Base base, File folder) {
239173
}
240174

241175

242-
List<LocalContribution> listContributions(Editor editor) {
176+
List<LocalContribution> listContributions(Base base, Editor editor) {
243177
List<LocalContribution> contribs = new ArrayList<>();
244178
switch (this) {
245179
case LIBRARY:
246-
contribs.addAll(editor.getMode().contribLibraries);
180+
if (editor != null) {
181+
contribs.addAll(editor.getMode().contribLibraries);
182+
}
247183
break;
248184
case TOOL:
249-
contribs.addAll(editor.getBase().getToolContribs());
185+
contribs.addAll(base.getToolContribs());
250186
break;
251187
case MODE:
252-
contribs.addAll(editor.getBase().getModeContribs());
188+
contribs.addAll(base.getModeContribs());
253189
break;
254190
case EXAMPLES:
255-
contribs.addAll(editor.getBase().getExampleContribs());
191+
contribs.addAll(base.getExampleContribs());
256192
break;
257193
}
258194
return contribs;
@@ -266,41 +202,11 @@ File getBackupFolder() {
266202

267203
File createBackupFolder(StatusPanel status) {
268204
File backupFolder = getBackupFolder();
269-
// if (backupFolder.isDirectory()) {
270-
// status.setErrorMessage("First remove the folder named \"old\" from the " +
271-
// getFolderName() + " folder in the sketchbook.");
272-
// return null;
273-
// }
274205
if (!backupFolder.exists() && !backupFolder.mkdirs()) {
275206
status.setErrorMessage("Could not create a backup folder in the " +
276207
"sketchbook " + this + " folder.");
277208
return null;
278209
}
279210
return backupFolder;
280211
}
281-
282-
283-
// /**
284-
// * Create a filter for a specific contribution type.
285-
// * @param type The type, or null for a generic update checker.
286-
// */
287-
// Contribution.Filter createFilter2() {
288-
// return new Contribution.Filter() {
289-
// public boolean matches(Contribution contrib) {
290-
// return contrib.getType() == ContributionType.this;
291-
// }
292-
// };
293-
// }
294-
295-
296-
// static Contribution.Filter createUpdateFilter() {
297-
// return new Contribution.Filter() {
298-
// public boolean matches(Contribution contrib) {
299-
// if (contrib instanceof LocalContribution) {
300-
// return ContributionListing.getInstance().hasUpdates(contrib);
301-
// }
302-
// return false;
303-
// }
304-
// };
305-
// }
306212
}

app/src/processing/app/contrib/LocalContribution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ LocalContribution copyAndLoad(Base base,
247247
Editor editor = base.getActiveEditor();
248248

249249
List<LocalContribution> oldContribs =
250-
getType().listContributions(editor);
250+
getType().listContributions(base, editor);
251251

252252
// In case an update marker exists, and the user wants to install, delete the update marker
253253
if (contribFolder.exists() && !contribFolder.isDirectory()) {

todo.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ X through sketch.properties is not rewritten
55
X dropping folder into sketch window throws weird exception
66
X https://github.com/processing/processing4/issues/441
77

8+
manager
9+
X "Error during download and install of Python Mode for Processing"
10+
X https://github.com/processing/processing/issues/5918
11+
X https://github.com/processing/processing4/issues/445
12+
X Manager fails to complete install of PythonMode when no windows open
13+
X https://github.com/processing/processing/issues/5309
14+
X https://github.com/processing/processing4/issues/446
15+
_ allow update of the current Mode
16+
17+
_ an incompatible Mode prevents the PDE from quitting after last window is closed
18+
_ https://github.com/processing/processing/issues/5112
19+
20+
21+
_ remove checkbox for detaching sketch name
22+
_ just do this manually, and Save As will reset the name
23+
24+
_ update wiki with recent changes (i.e. separating sketch folder)
25+
_ https://github.com/processing/processing4/wiki/Processing-4
26+
827
_ clicking "Update All" on the Updates tab throws NPE
928
_ https://github.com/processing/processing4/issues/440
1029
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "javax.swing.JProgressBar.setVisible(boolean)" because "this.progressBar" is null
@@ -813,12 +832,6 @@ _ e.g. ocd is broken in 0125 because of method signature changes
813832

814833
PDE / Manager
815834

816-
_ Manager fails to complete install of PythonMode when no windows open
817-
_ https://github.com/processing/processing/issues/5309
818-
_ Python Mode not downloading?
819-
_ https://github.com/processing/processing/issues/5918
820-
_ an incompatible Mode prevents the PDE from quitting after last window is closed
821-
_ https://github.com/processing/processing/issues/5112
822835
_ “could not move the contribution to the backup folder” message while updating
823836
_ problem is that any sketch that uses a library, the lib is stuck as "in use"
824837
_ https://github.com/processing/processing/issues/4973

0 commit comments

Comments
 (0)