[udig-devel] split editing windows => null pointer exception in "zoom to layer".

Vince Darley vince.darley at eurobios.com
Wed Nov 7 06:29:00 PST 2007


I get a bunch of exceptions with split windows.  It seems code like 
this is to blame:

RenderManagerAdapters.java:

                 case RenderPackage.VIEWPORT_MODEL__BOUNDS: {
                     if( ApplicationGISInternal.getActiveEditor().isVisible() )
                         refreshDirtyArea(msg);
                     break;
                 }

     public static MapEditor getActiveEditor() {
         try{
             final ArrayList<IEditorPart> editor = new 
ArrayList<IEditorPart>();

             PlatformGIS.syncInDisplayThread(
                 new Runnable() {
                     public void run() {
                         try {
                             editor.add(
                                 PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                 .getActivePage().getActiveEditor()
                             );
                         }
...
             if (editor.get(0) instanceof MapEditor) {
                 return (MapEditor)editor.get(0);
             }
...
                 return null;

with a split window, if the non-map page is active, but the map is 
still entirely visible, then getActiveEditor() will return null, and 
a null pointer exception will be thrown in RenderManagerAdapters and 
my event (right-click on layer and zoom-to-layer) will do nothing at all.

It seems to me that getActiveEditor() probably needs to be rewritten 
to get the most recent MapEditor that was active, or at least check 
if a map editor is visible even if it is not active.  Realistically 
'zoom to layer' ought to work on the last active map, since I might 
trigger that action even if I can't currently see the map (but am 
about to make it active).

regards,

Vince.




More information about the udig-devel mailing list