From 01081ed62d4305d7f5d5fad73010dd9599a190e8 Mon Sep 17 00:00:00 2001 From: khartlage Date: Fri, 30 Jul 2004 16:46:27 +0000 Subject: [PATCH 1/1] avoid NPE in BrowserView --- .../phpeditor/ShowExternalPreviewAction.java | 8 +++--- .../phpeclipse/views/browser/BrowserView.java | 27 +++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java index e2e76d2..32256fa 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java @@ -78,8 +78,8 @@ public static ShowExternalPreviewAction getInstance() { } ((BrowserView) part).setUrl(localhostURL); - } catch (PartInitException e) { - PHPeclipsePlugin.log(e); + } catch (Exception e) { + //PHPeclipsePlugin.log(e); } } } @@ -107,8 +107,8 @@ public static ShowExternalPreviewAction getInstance() { } ((BrowserView) part).refresh(); - } catch (PartInitException e) { - PHPeclipsePlugin.log(e); + } catch (Exception e) { + // PHPeclipsePlugin.log(e); } } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java index ebc76fe..a5171dc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java @@ -27,7 +27,14 @@ public class BrowserView extends ViewPart { * @see ViewPart#createPartControl */ public void createPartControl(Composite frame) { - instance = new PHPBrowser(frame); + try { + instance = new PHPBrowser(frame); + if (instance.browser==null) { + instance = null; + } + } catch(Exception e) { + instance = null; + } } /** * Called when we must grab focus. @@ -35,20 +42,28 @@ public class BrowserView extends ViewPart { * @see org.eclipse.ui.part.ViewPart#setFocus */ public void setFocus() { - instance.setFocus(); + if (instance!=null) { + instance.setFocus(); + } } /** * Called when the View is to be disposed */ public void dispose() { - instance.dispose(); - instance = null; + if (instance!=null) { + instance.dispose(); + instance = null; + } super.dispose(); } public void setUrl(String url) { - instance.browser.setUrl(url); + if (instance!=null) { + instance.browser.setUrl(url); + } } public void refresh() { - instance.browser.refresh(); + if (instance!=null) { + instance.browser.refresh(); + } } } -- 1.7.1