Beccari,

It appears that this is because null activity is being added to the
activity scheduler.

The typical way to add activities is through PNode.addActivity(), or
PRoot.addActivity(). Are you sure that your code isn't adding a null
activity?

I would recommend checking for null wherever you are calling one of
these "addActivity" methods and throwing an exception.

If you are sure your code isn't adding a null activity, then it sounds
like a concurrency issue, as Michael is suggesting. You should only
ever add activities on the EDT.

Perhaps you can find all the places in your code where you are adding
activities and add checking code like this:

if (myActivity == null) {
    throw new IllegalStateExceptoin();
}
if (!SwingUtilities.isEventDispatchThread()) {
   throw new IllegalStateException();
}
node.addActivity(myActivity);

... just to ensure your code is doing the right thing.


On Sun, Dec 18, 2011 at 11:50 AM, Michael Heuer <heue...@gmail.com> wrote:
> Hello Beccari,
>
> It would be helpful if we could create a unit test that reproduces this error.
>
> Are you adding activities from a thread other than the AWT event thread?
>
>   michael
>
>
> On Fri, Dec 16, 2011 at 10:31 AM, beccari.francesco
> <beccari.france...@gmail.com> wrote:
>> Sometimes, when i run my application, I have this exception and all
>> the activities terminate.
>> This happens when there are many activities at the same time.
>>
>> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
>>        at
>> edu.umd.cs.piccolo.activities.PActivityScheduler.getAnimating(PActivityScheduler.java:
>> 191)
>>        at edu.umd.cs.piccolo.PCanvas.getAnimating(PCanvas.java:353)
>>        at edu.umd.cs.piccolo.PCanvas.paintComponent(PCanvas.java:589)
>>        at javax.swing.JComponent.paint(JComponent.java:1029)
>>        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
>>        at javax.swing.RepaintManager
>> $PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
>>        at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:
>> 1410)
>>        at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
>>        at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
>>        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
>>        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:
>> 785)
>>        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:
>> 713)
>>        at
>> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:
>> 693)
>>        at javax.swing.SystemEventQueueUtilities
>> $ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
>>        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>>        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
>>        at java.awt.EventQueue.access$000(EventQueue.java:84)
>>        at java.awt.EventQueue$1.run(EventQueue.java:602)
>>        at java.awt.EventQueue$1.run(EventQueue.java:600)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.security.AccessControlContext
>> $1.doIntersectionPrivilege(AccessControlContext.java:87)
>>        at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
>>        at
>> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
>> 269)
>>        at
>> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
>> 184)
>>        at
>> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
>> 174)
>>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
>> 169)
>>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
>> 161)
>>        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
>>        at
>> edu.umd.cs.piccolo.activities.PActivityScheduler.processActivities(PActivityScheduler.java:
>> 175)
>>        at edu.umd.cs.piccolo.PRoot.processInputs(PRoot.java:332)
>>        at edu.umd.cs.piccolo.activities.PActivityScheduler
>> $1.actionPerformed(PActivityScheduler.java:222)
>>        at javax.swing.Timer.fireActionPerformed(Timer.java:291)
>>        at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
>>        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>>        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
>>        at java.awt.EventQueue.access$000(EventQueue.java:84)
>>        at java.awt.EventQueue$1.run(EventQueue.java:602)
>>        at java.awt.EventQueue$1.run(EventQueue.java:600)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.security.AccessControlContext
>> $1.doIntersectionPrivilege(AccessControlContext.java:87)
>>        at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
>>        at
>> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
>> 269)
>>        at
>> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
>> 184)
>>        at
>> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
>> 174)
>>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
>> 169)
>>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
>> 161)
>>        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>>
>> --
>> Piccolo2D Developers Group: 
>> http://groups.google.com/group/piccolo2d-dev?hl=en
>
> --
> Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

-- 
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to