Slick Forums

Discuss the Slick 2D Library
It is currently Sun Dec 17, 2017 6:02 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Jun 22, 2013 9:12 pm 
Offline

Joined: Sat Aug 13, 2011 8:04 pm
Posts: 87
Location: Canada
Hi Matthias,

I have a weird error, and it's very hard to replicate because it only happens occasionally. Maybe once every week (and I'm running my program a lot as I'm still developing it). It happens during the first few seconds of running, perhaps even on the first run through. I have some error trapping in place for serious errors, but after this happens once, it doesn't repeat and it appears the problem corrects itself, so I'd rather not abort the program.

So I'm wondering if you can make any suggestions, is this something I'm doing in a widget somewhere that is causing this error? Or can I safely trap this particular exception and do something different with it?

I'm pasting the place it's caught in the mainLoop() method (that I borrowed from your examples way back, so I hope it looks kinda familiar to you, plus the stack trace after this:

Thanks a lot for any suggestions
tomas

Code:
root = new RootPane();
renderer = new LWJGLRenderer();
renderer.setUseSWMouseCursors(true);
gui = new GUI(root, renderer);

loadTheme();

while (!Display.isCloseRequested() && !closeRequested) {
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

   render();

   try {
      gui.update();
      
   } catch (Exception e) {
      resourceManager.log(LOG_TYPE.error, this, "KeepYaBeat.mainLoop: uncaught error "+e.getMessage());
      e.printStackTrace();
      resourceManager.getGuiManager().warnOnErrorMessage(CoreLocalisation.Key.UNEXPECTED_PROGRAM_ERROR);
   }
   
   Display.update();


Code:
SEVERE 22-jun-2013 13:11 39 KeepYaBeat.mainLoop: uncaught error Index: 1, Size: 0
STDERR 22-jun-2013 13:11 40 java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
STDERR 22-jun-2013 13:11 41    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
STDERR 22-jun-2013 13:11 42    at java.util.ArrayList.get(ArrayList.java:322)
STDERR 22-jun-2013 13:11 43    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 44    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 45    at de.matthiasmann.twl.ScrollPane.validateLayout(ScrollPane.java:606)
STDERR 22-jun-2013 13:11 46    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 47    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 48    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 49    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 50    at de.matthiasmann.twl.Widget.validateLayout(Widget.java:1011)
STDERR 22-jun-2013 13:11 51    at de.matthiasmann.twl.GUI.validateLayout(GUI.java:521)
STDERR 22-jun-2013 13:11 52    at de.matthiasmann.twl.GUI.update(GUI.java:567)
STDERR 22-jun-2013 13:11 53    at com.stillwindsoftware.keepyabeat.KeepYaBeat.mainLoop(KeepYaBeat.java:352)
STDERR 22-jun-2013 13:11 54    at com.stillwindsoftware.keepyabeat.KeepYaBeat.run(KeepYaBeat.java:418)
STDERR 22-jun-2013 13:11 55    at com.stillwindsoftware.keepyabeat.KeepYaBeat.main(KeepYaBeat.java:119)


Top
 Profile  
 
PostPosted: Sat Jun 22, 2013 9:56 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Do you have any code accessing TWL from another thread? (eg KryoNet callbacks etc)

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Sat Jun 22, 2013 10:06 pm 
Offline

Joined: Sat Aug 13, 2011 8:04 pm
Posts: 87
Location: Canada
Hmmm... short answer is, well, maybe... I'll have a good look at it, as I do some startup stuff in another thread which notifies when it completes, so I better first check it puts that in the gui thread.

I'll get back to you, thanks for the clue :wink:

Edit update:
Yup, my loadup code executes in another thread and when it completes it calls back, just as you suggest. And it immediately starts adding buttons to the root pane.
I guess I should put this all into a gui.invokeLater() call, that will cure it, right?


Top
 Profile  
 
PostPosted: Sun Jun 23, 2013 4:42 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Yep :)

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Sun Jun 23, 2013 9:24 am 
Offline

Joined: Sat Aug 13, 2011 8:04 pm
Posts: 87
Location: Canada
Since my last response I made the change. I've run it lots of times and I've seen no more problems with it. I'm pretty confident it's solved, particularly because your inspiration makes sense, and because you immediately knew what it must be.

Thanks for your great expertise!
:D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group