Hi all,

this is my first post to the list, so I wanted to tell you I uDig is a great 
project. 

Unfortunately, at the moment I'm having problems with an error that occurs 
rather unpredictably.
When trying to add layers to a map, the following exception is thrown:

java.lang.NullPointerException
        at 
net.refractions.udig.project.ui.internal.RenderManagerAdapters.synchronizeRenderers(RenderManagerAdapters.java:327)
        at 
net.refractions.udig.project.ui.internal.RenderManagerAdapters.synchronizeAndRefresh(RenderManagerAdapters.java:281)
        at 
net.refractions.udig.project.ui.internal.RenderManagerAdapters.access$0(RenderManagerAdapters.java:280)
        at 
net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.manyLayersAdded(RenderManagerAdapters.java:178)
        at 
net.refractions.udig.project.internal.ContextModelListenerAdapter.notifyChanged(ContextModelListenerAdapter.java:85)
        at 
net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.notifyChanged(RenderManagerAdapters.java:142)
        at 
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
        at 
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1033)
        at 
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
        at 
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
        at 
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
        at 
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
        at 
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(NotifyingListImpl.java:468)
        at 
org.eclipse.emf.common.util.AbstractEList.addAll(AbstractEList.java:410)
        at 
net.refractions.udig.project.internal.commands.AddLayersCommand.run(AddLayersCommand.java:89)
        at 
net.refractions.udig.project.command.CommandManager$Executor.execute(CommandManager.java:400)
        at 
net.refractions.udig.project.command.CommandManager$Executor.run(CommandManager.java:325)
        at 
net.refractions.udig.project.command.CommandManager$Executor.run(CommandManager.java:311)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

>From what I found out with the debugger, the problem happens lies within the 
>following lines of RenderManagerAdapters.java:

        for( RenderContext newcontext : configuration2 ) {
            if (!oldToCopy.containsKey(newcontext)
                    && !(newcontext.getLayer() instanceof SelectionLayer)) {
                        ...
            } else {
                if (newcontext instanceof CompositeRenderContext) {
                    List<Layer> oldLayers = new 
ArrayList<Layer>(((CompositeRenderContext) oldToCopy.get(newcontext))
[Line 327]                          .getLayersInternal());
                        ...

Since this is the first time the map is to be rendered, the oldToCopy map is 
empty. 

I'm adding several layers to the map, for which automatically additional 
SelectionLayers are added. So I seem to have CompositeRenderContexts in 
configuration2 that contain SelectionLayers. Since they do not exist in the 
oldToCopy map, the getLayersInternal() call in the marked line goes on null, 
therefore the NullPointerException.

My questions are:
1) Does anybody know which kind of situation leads to this error?
2) How can I circumvent it? To me, it seems like some sort of timing problem.

Thanks in advance,
Thomas Ryssel

---
Fraunhofer-Institut für Verkehrs- und Infrastruktursysteme IVI
Zeunerstrasse 38
D-01069 Dresden

E-Mail:  [email protected]
WWW: www.ivi.fraunhofer.de
Tel.: +49 351 4640-696


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to