From: axelcl Date: Sat, 31 Mar 2007 09:28:52 +0000 (+0000) Subject: #1365431 (toshihiro) - PHP Editor crashes Windows with JavaScript 'windows.close()' X-Git-Url: http://git.phpeclipse.com?hp=05cb0614594a8bed9a1c34e3ca587086f62febab #1365431 (toshihiro) - PHP Editor crashes Windows with JavaScript 'windows.close()' --- diff --git a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/WebBrowser.java b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/WebBrowser.java index 4c4f9ee..961fd5d 100644 --- a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/WebBrowser.java +++ b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/WebBrowser.java @@ -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(); + } } }); diff --git a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java index 92face4..04a4cb7 100644 --- a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java +++ b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java @@ -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;