From a7f52f3d324e838e7bf2487c1b085808db2f1ca5 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Thu, 14 Dec 2017 13:55:59 +0300 Subject: [PATCH] Fix NPE introduced by PY-27227 (EA-113959) --- .../src/com/jetbrains/python/debugger/PyDebugSupportUtils.java | 2 +- .../com/jetbrains/python/debugger/PySetNextStatementAction.kt | 3 ++- .../com/jetbrains/python/debugger/PyStepIntoMyCodeAction.java | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java b/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java index 2e37bcad33bf..fafe7d3cf1e0 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java @@ -116,7 +116,7 @@ public class PyDebugSupportUtils { return false; } - public static boolean isCurrentPythonDebugProcess(Project project) { + public static boolean isCurrentPythonDebugProcess(@NotNull Project project) { XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession(); return session != null && session.getDebugProcess() instanceof PyDebugProcess; } diff --git a/python/src/com/jetbrains/python/debugger/PySetNextStatementAction.kt b/python/src/com/jetbrains/python/debugger/PySetNextStatementAction.kt index 7da663cbba60..6aa65fa0566b 100644 --- a/python/src/com/jetbrains/python/debugger/PySetNextStatementAction.kt +++ b/python/src/com/jetbrains/python/debugger/PySetNextStatementAction.kt @@ -71,7 +71,8 @@ class PySetNextStatementAction : XDebuggerActionBase(true) { override fun getHandler(debuggerSupport: DebuggerSupport) = setNextStatementActionHandler override fun isHidden(event: AnActionEvent): Boolean { - return !PyDebugSupportUtils.isCurrentPythonDebugProcess(event.getData(CommonDataKeys.PROJECT)) + val project = event.getData(CommonDataKeys.PROJECT) + return project == null || !PyDebugSupportUtils.isCurrentPythonDebugProcess(project) } companion object { diff --git a/python/src/com/jetbrains/python/debugger/PyStepIntoMyCodeAction.java b/python/src/com/jetbrains/python/debugger/PyStepIntoMyCodeAction.java index 5ddd3e0b8a3b..9ad940d6dbf0 100644 --- a/python/src/com/jetbrains/python/debugger/PyStepIntoMyCodeAction.java +++ b/python/src/com/jetbrains/python/debugger/PyStepIntoMyCodeAction.java @@ -58,6 +58,7 @@ public class PyStepIntoMyCodeAction extends XDebuggerActionBase { @Override protected boolean isHidden(AnActionEvent event) { - return !PyDebugSupportUtils.isCurrentPythonDebugProcess(event.getData(CommonDataKeys.PROJECT)); + Project project = event.getData(CommonDataKeys.PROJECT); + return project == null || !PyDebugSupportUtils.isCurrentPythonDebugProcess(project); } }