[Patchanim-commit] SF.net SVN: patchanim: [76] trunk/patchanim/src/com/mebigfatguy/patchanim/ gui/J
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-01-31 05:56:22
|
Revision: 76 http://patchanim.svn.sourceforge.net/patchanim/?rev=76&view=rev Author: dbrosius Date: 2008-01-30 21:56:26 -0800 (Wed, 30 Jan 2008) Log Message: ----------- synchronize the creation of the redraw thread so that there is only one redraw per patch at a time. Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-01-31 05:46:28 UTC (rev 75) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-01-31 05:56:26 UTC (rev 76) @@ -62,6 +62,7 @@ private OutOfBoundsColor oob; private BufferedImage image; private PatchDecorator decorator; + private Thread redrawThread = null; public JPatchSamplePanel(PatchColor c) { color = c; @@ -141,7 +142,19 @@ } public void recalcImage(final PatchColor color, final CombinedPatch patch) { - Thread t = new Thread(new Runnable() { + synchronized(this) { + if (redrawThread != null) { + try { + redrawThread.interrupt(); + redrawThread.join(); + } catch (InterruptedException ie) { + } finally { + redrawThread = null; + } + } + } + + redrawThread = new Thread(new Runnable() { public void run() { if (color == PatchColor.Combined) { PatchGenerator.recalcCombinedImage(patch, image, oob); @@ -150,9 +163,12 @@ } redraw(); + synchronized(this) { + redrawThread = null; + } } }); - t.start(); + redrawThread.start(); } private void redraw() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |