From d19b375a9eb1006ad02f81967a46156a11fce246 Mon Sep 17 00:00:00 2001
From: tobias <tobias@thecodedev.de>
Date: Thu, 5 Sep 2019 20:16:22 +0200
Subject: [PATCH] Fix null handling if no project is open in web api

---
 .../plugin/api/websocket/methods/ProjectCurrentMethod.scala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/websocket/methods/ProjectCurrentMethod.scala b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/websocket/methods/ProjectCurrentMethod.scala
index fd084b38..df30b50f 100644
--- a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/websocket/methods/ProjectCurrentMethod.scala
+++ b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/websocket/methods/ProjectCurrentMethod.scala
@@ -11,6 +11,10 @@ class ProjectCurrentMethod extends MethodExecutable {
 	override def execute(session: Session, message: Message): JsonObject = {
 		val currentProject = PlayPadPlugin.getInstance().getCurrentProject
 
-		ProjectSerializer.serializeProject(currentProject)
+		if (currentProject == null) {
+			new JsonObject
+		} else {
+			ProjectSerializer.serializeProject(currentProject)
+		}
 	}
 }
-- 
GitLab