#1365431 (toshihiro) - PHP Editor crashes Windows with JavaScript 'windows.close()'
authoraxelcl <axelcl>
Sat, 31 Mar 2007 09:28:52 +0000 (09:28 +0000)
committeraxelcl <axelcl>
Sat, 31 Mar 2007 09:28:52 +0000 (09:28 +0000)
net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/WebBrowser.java
net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java

index 4c4f9ee..961fd5d 100644 (file)
@@ -236,8 +236,10 @@ public class WebBrowser extends Composite {
                                // else its an editor window
                                if (shell != null)
                                        shell.dispose();
-                               else
-                                       editor.closeEditor();
+                               else {
+                                       // #1365431 (toshihiro) editor.closeEditor(); causes NPE
+                               if (editor != null) editor.closeEditor();
+                               }
                        }
                });
 
index 92face4..04a4cb7 100644 (file)
@@ -14,9 +14,11 @@ import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowser;
 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.browser.CloseWindowListener;
 import org.eclipse.swt.browser.ProgressListener;
 import org.eclipse.swt.browser.StatusTextListener;
 import org.eclipse.swt.browser.TitleListener;
+import org.eclipse.swt.browser.WindowEvent;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.part.IShowInTarget;
 import org.eclipse.ui.part.ShowInContext;
@@ -45,6 +47,15 @@ public class BrowserView extends ViewPart implements IShowInTarget {
                try {
                        if (WebBrowserUtil.isInternalBrowserOperational()) {
                                fInstance = new WebBrowser(frame, true, true);
+                               // #1365431 (toshihiro) start
+                               fInstance.getBrowser().addCloseWindowListener(
+                                               new CloseWindowListener() {
+                                                       public void close(WindowEvent event) {
+                                                               getViewSite().getPage().hideView(
+                                                                               BrowserView.this);
+                                                       }
+                                               });
+                               // #1365431 (toshihiro) end
                        }
                } catch (Exception e) {
                        fInstance = null;