Bug - Fixed r9412 with addCreationQueue set to false doesn't work

slyz

Developer
Continuing the discussion started in this thread, it looks like Mafia is unable to create the ItemManageFrame when the addCreationQueue setting is set to false in GLOBAL_prefs.txt. It then generates a (summary) debug log, and exits:
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v14.6 r9415, Windows XP, Java 1.6.0_24
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Jun 08 14:37:31 CEST 2011
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


net.sourceforge.kolmafia.swingui.ItemManageFrame could not be loaded
net.sourceforge.kolmafia.swingui.ItemManageFrame could not be loaded
net.sourceforge.kolmafia.swingui.ItemManageFrame could not be loaded
Unexpected error, debug log printed.
Unexpected error, debug log printed.
Unexpected error, debug log printed.
Error during session initialization
Unexpected error, debug log printed.

I tried changing
PHP:
super.setEnabled( isEnabled );
to
PHP:
if ( this.elementList == null || this.buttons == null )
{
	super.setEnabled( isEnabled );
	return;
}
in UseItemEnqueuePanel.java, but that doesn't fix the problem.
 

Veracity

Developer
Staff member
The stack trace:

Code:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4
	at net.sourceforge.kolmafia.swingui.panel.UseItemEnqueuePanel.setEnabled(UseItemEnqueuePanel.java:162)
	at net.sourceforge.kolmafia.KoLmafia.updateDisplayState(KoLmafia.java:668)
	at net.sourceforge.kolmafia.KoLmafia.updateDisplay(KoLmafia.java:649)
	at net.sourceforge.kolmafia.KoLmafia.updateDisplay(KoLmafia.java:624)
	at net.sourceforge.kolmafia.StaticEntity.printStackTrace(StaticEntity.java:1040)
	at net.sourceforge.kolmafia.StaticEntity.printStackTrace(StaticEntity.java:1015)
	at net.sourceforge.kolmafia.StaticEntity.printStackTrace(StaticEntity.java:1010)
	at net.sourceforge.kolmafia.KoLmafiaGUI.constructFrame(KoLmafiaGUI.java:290)
	at net.sourceforge.kolmafia.swingui.button.DisplayFrameButton.run(DisplayFrameButton.java:66)
	at net.sourceforge.kolmafia.swingui.button.ThreadedButton.actionPerformed(ThreadedButton.java:76)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.Component.processMouseEvent(Component.java:6374)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6139)
	at java.awt.Container.processEvent(Container.java:2085)
	at java.awt.Component.dispatchEventImpl(Component.java:4736)
	at java.awt.Container.dispatchEventImpl(Container.java:2143)
	at java.awt.Component.dispatchEvent(Component.java:4566)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
	at java.awt.Container.dispatchEventImpl(Container.java:2129)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4566)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)
	at java.awt.EventQueue.access$000(EventQueue.java:86)
	at java.awt.EventQueue$1.run(EventQueue.java:639)
	at java.awt.EventQueue$1.run(EventQueue.java:637)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:653)
	at java.awt.EventQueue$2.run(EventQueue.java:651)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

"java.lang.ArrayIndexOutOfBoundsException: 4" on this.buttons[4] in

Code:
		if ( this.booze )
		{
			this.buttons[ 4 ].setEnabled( havedrunk && ( havepill && !usedpill ) );
		}

And the reason it fails is this:

Code:
		if ( Preferences.getBoolean( "addCreationQueue" ) )
		{
			listeners.add( new EnqueueListener() );
		}
If you don't have a creation queue, you are missing a button...
 
Last edited:

slyz

Developer
I think I get it now... when addCreationQueue is false, buttons[ 4 ] doesn't exist.

EDIT: Ah, the stack trace would have told me that, thanks Veracity. I think you already posted somewhere how to obtain a stack trace, I should look that up.
 

Veracity

Developer
Staff member
Revision 9417

When you get an exception. always start your debugging with the stack trace. For me, on OS X, the stack trace is on the terminal window that I ran the .jar file from. I don't know where you find it on Windows.

I fixed another issue: if we are disabling the frame - we are autoadventuring, say - do not enable the button anyway.
 
Top