From 4a35720457e802ea651c3a1666b9cd2c84aef013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:23:02 +0200 Subject: [PATCH] IDEMPIERE-5686 - Closing Browser Tab while Process Modal Dialog is Opened causes NPE (#1797) * IDEMPIERE-5686 - Closing Browser Tab while Process Modal Dialog is Opened causes NPE * IDEMPIERE-5686 - fixes * IDEMPIERE-5650 - WProcessCtl fix * IDEMPIERE-5650 - move check to ShowMaskWrapper --- .../WEB-INF/src/org/adempiere/webui/ShowMaskWrapper.java | 7 +++++-- .../WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ShowMaskWrapper.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ShowMaskWrapper.java index dcf9e1e4bf..487c8a10bb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ShowMaskWrapper.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ShowMaskWrapper.java @@ -18,6 +18,7 @@ import org.adempiere.webui.component.Mask; import org.adempiere.webui.part.UIPart; import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.util.Clients; /** @@ -113,7 +114,8 @@ public class ShowMaskWrapper implements ISupportMask { * @param comp */ public static void setFlagShowMask (Component comp){ - comp.setAttribute(ISupportMask.READY_SHOW_MASK_FLAG, Integer.valueOf(1), Component.REQUEST_SCOPE); + if(Executions.getCurrent() != null && Executions.getCurrent().getNativeRequest() != null) + comp.setAttribute(ISupportMask.READY_SHOW_MASK_FLAG, Integer.valueOf(1), Component.REQUEST_SCOPE); } /** @@ -122,6 +124,7 @@ public class ShowMaskWrapper implements ISupportMask { * @return true if flag exists */ public static boolean hasFlagShowMask (Component comp){ - return (comp.getAttribute(ISupportMask.READY_SHOW_MASK_FLAG, Component.REQUEST_SCOPE) != null); + return (Executions.getCurrent() != null && Executions.getCurrent().getNativeRequest() != null) + && (comp.getAttribute(ISupportMask.READY_SHOW_MASK_FLAG, Component.REQUEST_SCOPE) != null); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index def96bf9dc..36364b2261 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -2443,6 +2443,8 @@ public abstract class InfoPanel extends Window implements EventListener, createT_Selection_InfoWindow(pInstanceID); recordSelectedData.clear(); }else if (ProcessModalDialog.ON_WINDOW_CLOSE.equals(event.getName())){ + if (getDesktop() == null) + return; if (processModalDialog.isCancel()){ //clear back m_results.clear();