amitsarangi / mt4j

Automatically exported from code.google.com/p/mt4j
GNU General Public License v2.0
0 stars 0 forks source link

Problem with a list in draw and update #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. add a mousemotionlistener to a scene
2. a global input listener implements i.e. only mousemotionlistener interface
3.

What is the expected output? What do you see instead?
after a time, the animation thread dies. 

What version of the product are you using? On what operating system?
0.9 - Windows 7, x64

Please provide any additional information below.
Exception in thread "Animation Thread" java.lang.IndexOutOfBoundsException: 
Index: 6, Size: 13
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at org.mt4j.components.visibleComponents.widgets.MTTextArea.drawComponent(MTTextArea.java:344)
    at org.mt4j.components.MTCanvas.drawUpdateRecursive(MTCanvas.java:401)
    at org.mt4j.components.MTCanvas.drawUpdateRecursive(MTCanvas.java:375)
    at org.mt4j.components.MTCanvas.drawAndUpdateCanvas(MTCanvas.java:313)
    at org.mt4j.sceneManagement.AbstractScene.drawAndUpdate(AbstractScene.java:166)
    at org.mt4j.MTApplication.runApplication(MTApplication.java:622)
    at org.mt4j.MTApplication.draw(MTApplication.java:554)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:619)

Original issue reported on code.google.com by ajaenc...@gmail.com on 5 Jul 2010 at 8:39

GoogleCodeExporter commented 9 years ago
Can you provide some source code for this? You can use a site like pastebin or 
pastie.org or attach it. Im not sure how to reproduce this exactly.
If the error only occurs from time to time it may be a timing/threading issue. 
You should not modify a MT4j application from within a different thread as the 
Animation Thread (like in a mousemotion listener).
Instead you can wrap the action into a invokeLater action to make it thread 
safe calling it from another thread. The action will be exectuted the next 
frame in the animation thread.
E.g.:
void mouseMoved(){ 
mtApplication.invokeLater(new Runnable(){  public void run(){ //do mt4j stuff 
here} });
}

A similar method is described here:
http://www.mt4j.org/mediawiki/index.php/FAQ#How_to_avoid_threading_problems_.3F

Original comment by sirhc.f...@gmail.com on 5 Jul 2010 at 1:41

GoogleCodeExporter commented 9 years ago
Closing this since no answer and I couldnt reproduce it.

Original comment by sirhc.f...@gmail.com on 11 Aug 2010 at 6:41

GoogleCodeExporter commented 9 years ago
I had a similar problem with an MTTextArea.  I was modifying the text off of 
the animation thread.  Just have to remember to modify components from other 
threads using MTApplication.invokeLater(), the same way you have to modify 
swing components using SwingUtilitities.invokeLater().

Original comment by drran...@gmail.com on 3 Mar 2011 at 7:42