ikuraj / alloy4eclipse

Automatically exported from code.google.com/p/alloy4eclipse
0 stars 0 forks source link

A4E answer viewer needs to wait until A4 viz has actually displayed the graph before accessing it #46

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Load a test Alloy spec that has a solution instance
2. Select the solution *.xml file
3. Context menu => open with Alloy Answer Viewer

What is the expected output? 
A new Eclipse viewer with the A4 visualization

What do you see instead?

At line 360, viewer == null.
This will cause a NPE.

Thread [main] (Suspended (breakpoint at line 360 in MultiPageEditor))   
    MultiPageEditor.addPage(String, URL) line: 360  
    MultiPageEditor.createPage2() line: 252 
    MultiPageEditor.createPages() line: 386 
    MultiPageEditor(MultiPageEditorPart).createPartControl(Composite) line: 276 
    EditorReference.createPartHelper() line: 596    
    EditorReference.createPart() line: 372  
    EditorReference(WorkbenchPartReference).getPart(boolean) line: 566  
    EditorReference.getEditor(boolean) line: 214    
    WorkbenchPage.busyOpenEditorBatched(IEditorInput, String, boolean, int)
line: 2595  
    WorkbenchPage.busyOpenEditor(IEditorInput, String, boolean, int) line: 2528 
    WorkbenchPage.access$10(WorkbenchPage, IEditorInput, String, boolean, int)
line: 2520  
    WorkbenchPage$9.run() line: 2505    
    BusyIndicator.showWhile(Display, Runnable) line: 67 
    WorkbenchPage.openEditor(IEditorInput, String, boolean, int) line: 2500 
    OpenWithMenu.openEditor(IEditorDescriptor) line: 288    
    OpenWithMenu.access$0(OpenWithMenu, IEditorDescriptor) line: 280    
    OpenWithMenu$2.handleEvent(Event) line: 184 
    EventTable.sendEvent(Event) line: 66    
    MenuItem(Widget).sendEvent(Event) line: 928 
    Display.runDeferredEvents() line: 3348  
    Display.readAndDispatch() line: 2968    
    Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1930    
    Workbench.runUI() line: 1894    
    Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 422    
    PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149   
    IDEApplication.run(Object) line: 95 
    PlatformActivator$1.run(Object) line: 78    
    EclipseAppLauncher.runApplication(Object) line: 92  
    EclipseAppLauncher.start(Object) line: 68   
    EclipseStarter.run(Object) line: 400    
    EclipseStarter.run(String[], Runnable) line: 177    
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]   
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 64  
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43  
    Method.invoke(Object, Object...) line: 615  
    Main.invokeFramework(String[], URL[]) line: 336 
    Main.basicRun(String[]) line: 280   
    Main.run(String[]) line: 977    
    Main.main(String[]) line: 952   

Please use labels and text to provide additional information.

At line 360, the state of viz[0] is consistent with the call to
viz[0].loadXML(...) from line 348. However, since the Swing/SWT
visualization runs asynchronously w.r.t. there is a significant potential
for a race condition with the thread that executes the code in
MultiPageEditor, line 359:

final VizViewer viewer = viz[0].getViewer();

If this code executes "too early", then viewer == null and we get NPE at
line 360.

The workaround is either to ask the A4 developers to make getViewer() a
blocking call to ensure it returns a non-null answer once the Swing/SWT
thread has performed the necessary update work or for A4E to define a
wrapper to do this.

Original issue reported on code.google.com by nicolas....@gmail.com on 12 Feb 2008 at 10:34