diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 877ead4c9..6f018aaa8 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -46,9 +46,9 @@ import processing.mode.java.JavaMode; public class Base { // Added accessors for 0218 because the UpdateCheck class was not properly // updating the values, due to javac inlining the static final values. - static private final int REVISION = 225; + static private final int REVISION = 226; /** This might be replaced by main() if there's a lib/version.txt file. */ - static private String VERSION_NAME = "0225"; //$NON-NLS-1$ + static private String VERSION_NAME = "0226"; //$NON-NLS-1$ /** Set true if this a proper release rather than a numbered revision. */ // static private boolean RELEASE = false; @@ -607,13 +607,30 @@ public class Base { Base.showWarning("Save", "Please save the sketch before changing the mode.", null); + return; + } + nextMode = mode; + + // If the current editor contains file extensions that the new mode can handle, then + // write a sketch.properties file with the new mode specified, and reopen. + boolean newModeCanHandleCurrentSource = true; + for (final SketchCode code: sketch.getCode()) { + if (!mode.validExtension(code.getExtension())) { + newModeCanHandleCurrentSource = false; + break; + } + } + if (newModeCanHandleCurrentSource) { + final File props = new File(sketch.getCodeFolder(), "sketch.properties"); + saveModeSettings(props, nextMode); + handleClose(activeEditor, true); + handleOpen(sketch.getMainFilePath()); } else { // If you're changing modes, and there's nothing in the current sketch, you probably // don't intend to keep the old, wrong-mode editor around. if (sketch.isUntitled()) { handleClose(activeEditor, true); } - nextMode = mode; handleNew(); } } @@ -729,15 +746,7 @@ public class Base { } // Create sketch properties. - final File sketchProps = new File(newbieDir, "sketch.properties"); - try { - final Settings settings = new Settings(sketchProps); - settings.set("mode", nextMode.getTitle()); - settings.set("mode.id", nextMode.getIdentifier()); - settings.save(); - } catch (IOException e) { - System.err.println("While creating " + sketchProps + ": " + e.getMessage()); - } + saveModeSettings(new File(newbieDir, "sketch.properties"), nextMode); String path = newbieFile.getAbsolutePath(); /*Editor editor =*/ handleOpen(path, true); @@ -749,6 +758,18 @@ public class Base { } } + // Create or modify a sketch.proprties file to specify the given Mode. + private void saveModeSettings(final File sketchProps, final Mode mode) { + try { + final Settings settings = new Settings(sketchProps); + settings.set("mode", mode.getTitle()); + settings.set("mode.id", mode.getIdentifier()); + settings.save(); + } catch (IOException e) { + System.err.println("While creating " + sketchProps + ": " + e.getMessage()); + } + } + // /** // * Replace the sketch in the current window with a new untitled document. @@ -1053,10 +1074,11 @@ public class Base { return null; } - /** * Close a sketch as specified by its editor window. * @param editor Editor object of the sketch to be closed. + * @param modeSwitch Whether this close is being done in the context of a + * mode switch. * @return true if succeeded in closing, false if canceled. */ public boolean handleClose(Editor editor, boolean modeSwitch) { diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index dc609ae81..741474606 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -1046,6 +1046,18 @@ public abstract class Mode { abstract public String getDefaultExtension(); + /** + * Returns the appropriate file extension to use for auxilliary source files in a sketch. + * For example, in a Java-mode sketch, auxilliary files should be name "Foo.java"; in + * Python mode, they should be named "foo.py". + * + *

Modes that do not override this function will get the default behavior of returning the + * default extension. + */ + public String getModuleExtension() { + return getDefaultExtension(); + } + /** * Returns a String[] array of proper extensions. diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 198eadeec..20e96b56e 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -333,9 +333,6 @@ public class Sketch { /** * This is called upon return from entering a new file name. * (that is, from either newCode or renameCode after the prompt) - * This code is almost identical for both the newCode and renameCode - * cases, so they're kept merged except for right in the middle - * where they diverge. */ protected void nameCode(String newName) { newName = newName.trim(); @@ -348,7 +345,7 @@ public class Sketch { // Add the extension here, this simplifies some of the logic below. if (newName.indexOf('.') == -1) { - newName += "." + mode.getDefaultExtension(); + newName += "." + (renamingCode ? mode.getDefaultExtension() : mode.getModuleExtension()); } // if renaming to the same thing as before, just ignore. diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 09ba24faf..ca6f2da4e 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -122,6 +122,7 @@ class ContributionPanel extends JPanel { updateButton.setEnabled(false); installRemoveButton.setEnabled(false); installProgressBar.setVisible(true); + installProgressBar.setIndeterminate(true); ((LocalContribution) contrib).removeContribution(listPanel.contribManager.editor, new JProgressMonitor(installProgressBar) { @@ -484,7 +485,7 @@ class ContributionPanel extends JPanel { protected void resetInstallProgressBarState() { installProgressBar.setString("Starting"); - installProgressBar.setIndeterminate(true); + installProgressBar.setIndeterminate(false); installProgressBar.setValue(0); installProgressBar.setVisible(false); } diff --git a/app/src/processing/mode/java/runner/Runner.java b/app/src/processing/mode/java/runner/Runner.java index 9bea617b5..314e37f0d 100644 --- a/app/src/processing/mode/java/runner/Runner.java +++ b/app/src/processing/mode/java/runner/Runner.java @@ -678,7 +678,9 @@ public class Runner implements MessageConsumer { for (Event event : eventSet) { // System.out.println("EventThread.handleEvent -> " + event); - if (event instanceof ExceptionEvent) { + if (event instanceof VMStartEvent) { + vm.resume(); + } else if (event instanceof ExceptionEvent) { // for (ThreadReference thread : vm.allThreads()) { // System.out.println("thread : " + thread); //// thread.suspend(); @@ -710,8 +712,6 @@ public class Runner implements MessageConsumer { errThread.start(); outThread.start(); - vm.resume(); - // Shutdown begins when event thread terminates try { if (eventThread != null) eventThread.join(); // is this the problem? diff --git a/build/build.xml b/build/build.xml index 38c42244d..2b3d91b8d 100755 --- a/build/build.xml +++ b/build/build.xml @@ -20,13 +20,12 @@ + Java 1.8 caused build problems (with ECJ?) so not supported. --> - @@ -152,7 +151,7 @@ - + @@ -630,12 +629,20 @@ With a proper ID, if code signing fails, you may need to use: export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate" - - + + + + + + + + + + + + - - diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index 304242672..0f7004242 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -1,4 +1,4 @@ -PROCESSING 2.1.2 (REV 0225) - 11 April 2014 +PROCESSING 2.1.2 (REV 0225) - 15 April 2014 Lots of small bug fixes plus some additional changes to support the new Python Mode, coming soon: https://github.com/jdf/processing.py @@ -6,6 +6,11 @@ the new Python Mode, coming soon: https://github.com/jdf/processing.py [ the pde ] ++ The PDE was using 15% of CPU while just sitting idle. Thanks to + David Fokkema for the fix (and pull request). + https://github.com/processing/processing/issues/1561 + https://github.com/processing/processing/pull/2451 + + Fix exception caused by Runner when it can't find location https://github.com/processing/processing/issues/2346 https://github.com/processing/processing/pull/2359 @@ -22,9 +27,15 @@ the new Python Mode, coming soon: https://github.com/jdf/processing.py + Remove some hardcoding for .pde as extension https://github.com/processing/processing/issues/2420 ++ Update code signing for Processing.app for Mavericks changes + https://github.com/processing/processing/issues/2453 + [ the core ] ++ sketchPath() was returning user.home in exported apps on OS X + https://github.com/processing/processing/issues/2181 + + Fix bug in StringDict(Reader) that wasn't setting the indices hashmap + Call revalidate() via reflection so that build works under 1.6 (using diff --git a/core/build.xml b/core/build.xml index 1e6a0455d..8bb8b3a2c 100755 --- a/core/build.xml +++ b/core/build.xml @@ -22,6 +22,7 @@ else="modern"> + type = list.getClass().getComponentType(); + Object outgoing = null; int length = Array.getLength(list); // check whether item being spliced in is an array if (value.getClass().getName().charAt(0) == '[') { int vlength = Array.getLength(value); - outgoing = new Object[length + vlength]; + outgoing = Array.newInstance(type, length + vlength); System.arraycopy(list, 0, outgoing, 0, index); System.arraycopy(value, 0, outgoing, index, vlength); System.arraycopy(list, index, outgoing, index + vlength, length - index); } else { - outgoing = new Object[length + 1]; + outgoing = Array.newInstance(type, length + 1); System.arraycopy(list, 0, outgoing, 0, index); Array.set(outgoing, index, value); System.arraycopy(list, index, outgoing, index + 1, length - index); @@ -10525,7 +10597,29 @@ public class PApplet extends Applet String folder = null; try { folder = System.getProperty("user.dir"); - } catch (Exception e) { } +// println("user dir is " + folder); + + // Workaround for bug in Java for OS X from Oracle (7u51) + // https://github.com/processing/processing/issues/2181 + if (platform == MACOSX) { + String jarPath = + PApplet.class.getProtectionDomain().getCodeSource().getLocation().getPath(); +// println("jar path: " + jarPath); + // The jarPath from above will be URL encoded (%20 for spaces) + jarPath = urlDecode(jarPath); +// println("decoded jar path: " + jarPath); + if (jarPath.contains("Contents/Java/")) { + String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4); + File containingFolder = new File(appPath).getParentFile(); + folder = containingFolder.getAbsolutePath(); +// println("folder is " + folder); + } +// } else { +// println("platform is " + platform); + } + } catch (Exception e) { + e.printStackTrace(); + } int argIndex = 0; while (argIndex < args.length) { diff --git a/core/src/processing/core/PVector.java b/core/src/processing/core/PVector.java index 1d2bd4b8a..58f86da3d 100644 --- a/core/src/processing/core/PVector.java +++ b/core/src/processing/core/PVector.java @@ -322,7 +322,7 @@ public class PVector implements Serializable { * @webref pvector:method * @usage web_application * @brief Make a new 2D unit vector from an angle - * @param angle the angle + * @param angle the angle in radians * @return the new unit PVector */ static public PVector fromAngle(float angle) { diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 8dd7b73a6..d98a9db51 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -1165,7 +1165,12 @@ public class Table { output.writeDouble(row.getDouble(col)); break; case CATEGORY: - output.writeInt(columnCategories[col].index(row.getString(col))); + String peace = row.getString(col); + if (peace.equals(missingString)) { + output.writeInt(missingCategory); + } else { + output.writeInt(columnCategories[col].index(peace)); + } break; } } @@ -2087,7 +2092,12 @@ public class Table { if (piece == null) { indexData[row] = missingCategory; } else { - indexData[row] = columnCategories[col].index(String.valueOf(piece)); + String peace = String.valueOf(piece); + if (peace.equals(missingString)) { // missingString might be null + indexData[row] = missingCategory; + } else { + indexData[row] = columnCategories[col].index(peace); + } } break; default: @@ -2933,6 +2943,9 @@ public class Table { } + /** + * Treat entries with this string as "missing". Also used for categorial. + */ public void setMissingString(String value) { missingString = value; } @@ -3562,6 +3575,7 @@ public class Table { read(input); } + /** gets the index, and creates one if it doesn't already exist. */ int index(String key) { Integer value = dataToIndex.get(key); if (value != null) { @@ -4131,7 +4145,12 @@ public class Table { } break; case CATEGORY: - output.writeInt(columnCategories[col].index(pieces[col])); + String peace = pieces[col]; + if (peace.equals(missingString)) { + output.writeInt(missingCategory); + } else { + output.writeInt(columnCategories[col].index(peace)); + } break; } } diff --git a/core/src/processing/opengl/Texture.java b/core/src/processing/opengl/Texture.java index f74da6a6e..db3c165e9 100644 --- a/core/src/processing/opengl/Texture.java +++ b/core/src/processing/opengl/Texture.java @@ -1267,7 +1267,7 @@ public class Texture implements PConstants { pg.setFramebuffer(tempFbo); // Clear the color buffer to make sure that the alpha channel is set to // full transparency - pgl.clearColor(1, 1, 1, 1); + pgl.clearColor(0, 0, 0, 0); pgl.clear(PGL.COLOR_BUFFER_BIT); if (scale) { // Rendering tex into "this", and scaling the source rectangle diff --git a/core/todo.txt b/core/todo.txt index ca651de95..83928da74 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,50 +1,10 @@ -0225 core -X bug with StringDict(Reader) that wasn't setting the indices hashmap -X check this with other versions of this class -X call revalidate() via reflection -X text looks lousy compared to the Apple JVM -X mess with rendering hints? (notes in PGraphicsJava2D) -X improvements made, but still not amazing.. just at level of Windows/Linux -o XML.getChildren() throwing NPE when getInt() called on non-existent var -o https://github.com/processing/processing/issues/2367 -X PGraphics.colorCalcARGB(int, float) doesn't cap alpha -X https://github.com/processing/processing/issues/2439 -X run window border color changed in 2.1 -X https://github.com/processing/processing/issues/2297 -X simple NPE issue that needs workaround -X https://github.com/processing/processing/issues/2354 +0226 core +X fix parsing with missing categorical values -fixed in 2.1 -X draw() called again before finishing on OS X (retina issue) -X https://github.com/processing/processing/issues/1709 -X get() not always setting alpha channel when used with point() -X https://github.com/processing/processing/issues/1756 -A support for geometry and tessellation shaders (on desktop) -A https://github.com/processing/processing/issues/2252 - -andres -X copy() under OPENGL uses upside-down coordinates for cropping -X https://github.com/processing/processing/issues/2345 -X video on windows causes exception -X https://github.com/processing/processing/issues/2327 -X Shape Font Rendering was broken with the OpenGL Renderer -X https://github.com/processing/processing/issues/2375 -A depth buffer shouldn't be cleared when depth mask is disabled -A https://github.com/processing/processing/issues/2296 -A set pixels transparent by default in P2D/P3D -A https://github.com/processing/processing/issues/2207 -A unwind depth sorting because it was breaking DXF export -A https://github.com/processing/processing/issues/2404 -A Sketch hangs if sketchRenderer() returns an OpenGL renderer -A https://github.com/processing/processing/issues/2363 -A "buffer" uniform triggers shader compilation error -A https://github.com/processing/processing/issues/2325 -A buffer has been renamed to ppixels for shaders -A noLoop clears screen on Windows 8 -A https://github.com/processing/processing/issues/2416 -A fix pixels[] array for video capture -A https://github.com/processing/processing/issues/2424 +_ XML.getChildren() throwing NPE when getInt() called on non-existent var +_ https://github.com/processing/processing/issues/2367 +_ need to sort out with docs what's happening here _ point() rendering differently in 2.0.3 and 2.1 _ https://github.com/processing/processing/issues/2278 diff --git a/done.txt b/done.txt index c99b1e8e5..b3e569697 100644 --- a/done.txt +++ b/done.txt @@ -1,3 +1,29 @@ +0225 pde (2.1.2) +X Fix exception caused by Runner when it can't find location +X https://github.com/processing/processing/issues/2346 +X https://github.com/processing/processing/pull/2359 +G Serial: Update to latest upstream (fixes potential port handle leak) +G https://github.com/processing/processing/pull/2361 +J add affordance for mode developers to run from Eclipse +J https://github.com/processing/processing/pull/2422 +J non-pde extensions for modes cause a crash +J https://github.com/processing/processing/issues/2419 +J some hardcoding for .pde still exists +J https://github.com/processing/processing/issues/2420 +X the PDE uses 15% of CPU while just sitting idle (thx to David Fokkema) +X https://github.com/processing/processing/issues/1561 +X https://github.com/processing/processing/pull/2451 +X Update code signing for Processing.app for Mavericks changes +X https://github.com/processing/processing/issues/2453 +o use --deep for codesign to work? (nope) +o http://furbo.org/2013/10/17/code-signing-and-mavericks/ +o http://brockerhoff.net/RB/AppCheckerLite/ +J permit modes to specify alternate extension (.py for .pyde stuff) +J https://github.com/processing/processing/pull/2452 +X sketchPath() returns user.home in exported apps on OSX +X https://github.com/processing/processing/issues/2181 + + 0224 pde (2.1.1) M fix infinite loop in Find/Replace M https://github.com/processing/processing/issues/2082 diff --git a/java/libraries/net/src/processing/net/Client.java b/java/libraries/net/src/processing/net/Client.java index 18867e5dc..de39b6e9f 100644 --- a/java/libraries/net/src/processing/net/Client.java +++ b/java/libraries/net/src/processing/net/Client.java @@ -118,6 +118,7 @@ public class Client implements Runnable { * @throws IOException */ public Client(PApplet parent, Socket socket) throws IOException { + this.parent = parent; this.socket = socket; input = socket.getInputStream(); @@ -125,6 +126,16 @@ public class Client implements Runnable { thread = new Thread(this); thread.start(); + + // reflection to check whether host sketch has a call for + // public void disconnectEvent(processing.net.Client) + try { + disconnectEventMethod = + parent.getClass().getMethod("disconnectEvent", + new Class[] { Client.class }); + } catch (Exception e) { + // no such method, or an error.. which is fine, just ignore + } } @@ -140,7 +151,7 @@ public class Client implements Runnable { * @usage application */ public void stop() { - if (disconnectEventMethod != null) { + if (disconnectEventMethod != null && thread != null){ try { disconnectEventMethod.invoke(parent, new Object[] { this }); } catch (Exception e) { diff --git a/java/libraries/net/src/processing/net/Server.java b/java/libraries/net/src/processing/net/Server.java index 12b73a71b..b9d076fba 100644 --- a/java/libraries/net/src/processing/net/Server.java +++ b/java/libraries/net/src/processing/net/Server.java @@ -24,12 +24,14 @@ */ package processing.net; + import processing.core.*; import java.io.*; import java.lang.reflect.*; import java.net.*; + /** * ( begin auto-generated from Server.xml ) * @@ -109,8 +111,7 @@ public class Server implements Runnable { * @param client the client to disconnect */ public void disconnect(Client client) { - //client.stop(); - client.dispose(); + client.stop(); int index = clientIndex(client); if (index != -1) { removeIndex(index); @@ -129,6 +130,21 @@ public class Server implements Runnable { } + protected void disconnectAll() { + synchronized (clients) { + for (int i = 0; i < clientCount; i++) { + try { + clients[i].stop(); + } catch (Exception e) { + // ignore + } + clients[i] = null; + } + clientCount = 0; + } + } + + protected void addClient(Client client) { if (clientCount == clients.length) { clients = (Client[]) PApplet.expand(clients); @@ -216,9 +232,7 @@ public class Server implements Runnable { thread = null; if (clients != null) { - for (int i = 0; i < clientCount; i++) { - disconnect(clients[i]); - } + disconnectAll(); clientCount = 0; clients = null; } @@ -311,15 +325,4 @@ public class Server implements Runnable { } } } - - - /** - * General error reporting, all corralled here just in case - * I think of something slightly more intelligent to do. - */ -// public void errorMessage(String where, Exception e) { -// parent.die("Error inside Server." + where + "()", e); -// //System.err.println("Error inside Server." + where + "()"); -// //e.printStackTrace(System.err); -// } } diff --git a/java/libraries/video/src/processing/video/Movie.java b/java/libraries/video/src/processing/video/Movie.java index 9707d3c61..93a74ab64 100644 --- a/java/libraries/video/src/processing/video/Movie.java +++ b/java/libraries/video/src/processing/video/Movie.java @@ -297,33 +297,38 @@ public class Movie extends PImage implements PConstants { * @brief Jumps to a specific location */ public void jump(float where) { - if (seeking) return; + if (seeking) return; // don't seek again until the current seek operation is done. if (!sinkReady) { initSink(); } // Round the time to a multiple of the source framerate, in - // order to eliminate stutter. Suggested by Daniel Shiffman + // order to eliminate stutter. Suggested by Daniel Shiffman float fps = getSourceFrameRate(); int frame = (int)(where * fps); - where = frame / fps; + final float seconds = frame / fps; + + // Put the seek operation inside a thread to avoid blocking the main + // animation thread + Thread seeker = new Thread() { + @Override + public void run() { + long pos = Video.secToNanoLong(seconds); + boolean res = playbin.seek(rate, Format.TIME, SeekFlags.FLUSH, + SeekType.SET, pos, SeekType.NONE, -1); + if (!res) { + PGraphics.showWarning("Seek operation failed."); + } - boolean res; - long pos = Video.secToNanoLong(where); - - res = playbin.seek(rate, Format.TIME, SeekFlags.FLUSH, - SeekType.SET, pos, SeekType.NONE, -1); - - if (!res) { - PGraphics.showWarning("Seek operation failed."); - } - - // getState() will wait until any async state change - // (like seek in this case) has completed - seeking = true; - playbin.getState(); - seeking = false; + // getState() will wait until any async state change + // (like seek in this case) has completed + seeking = true; + playbin.getState(); + seeking = false; + } + }; + seeker.start(); } diff --git a/todo.txt b/todo.txt index c625ed9e8..23b39471e 100644 --- a/todo.txt +++ b/todo.txt @@ -1,24 +1,12 @@ -0225 pde -X Fix exception caused by Runner when it can't find location -X https://github.com/processing/processing/issues/2346 -X https://github.com/processing/processing/pull/2359 -G Serial: Update to latest upstream (fixes potential port handle leak) -G https://github.com/processing/processing/pull/2361 -J add affordance for mode developers to run from Eclipse -J https://github.com/processing/processing/pull/2422 -J non-pde extensions for modes cause a crash -J https://github.com/processing/processing/issues/2419 -J some hardcoding for .pde still exists -J https://github.com/processing/processing/issues/2420 +0226 pde high -_ use --deep for codesign to work? -_ http://furbo.org/2013/10/17/code-signing-and-mavericks/ +_ sketch sometimes simply does not launch +_ https://github.com/processing/processing/issues/2402 +_ https://github.com/processing/processing/pull/2455 _ exported apps reporting as "damaged" on OS X _ https://github.com/processing/processing/issues/2095 -_ sketchPath() returns user.home in exported apps on OSX -_ https://github.com/processing/processing/issues/2181 _ QuickReference tool was able to bring down the environment _ https://github.com/processing/processing/issues/2229 _ tab characters not recognized/drawn in the editor (2.1) @@ -35,6 +23,8 @@ _ maybe OS X Java can't look in subfolders? (just auto-adds things) medium +_ re/move things from Google Code downloads +_ https://code.google.com/p/support/wiki/DownloadsFAQ _ actual help with cleaning out the repo _ https://github.com/processing/processing/issues/1898 _ requires re-forking, so still a ton of work @@ -388,8 +378,6 @@ _ active editor not being set null _ in Base.nextEditorLocation(), changed to "editors.size() == 0" _ instead of (activeEditor == null), but that's papering over a problem _ where the active editor is not being set null -_ the PDE uses 15% of CPU while just sitting idle -_ https://github.com/processing/processing/issues/1561 _ renaming RGB (.pde) to Rgb.java says "a file named RGB.pde already exists" _ improve update check message "a new release (1.0.1) is available" _ be more descriptive, use a second line in latest.txt