From cec880849648b7a8d65d290eb774422cd8d844eb Mon Sep 17 00:00:00 2001
From: tobias <thinkdifferent055@gmail.com>
Date: Sat, 21 Jan 2023 21:53:31 +0100
Subject: [PATCH] Fixed #185 -  Remove pad from old page even if new pad is
 null. Prevent issue of removing wrong pad on multipage move drag & drop
 action

---
 .../main/java/de/tobias/playpad/project/Project.java  | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/project/Project.java b/PlayWallCore/src/main/java/de/tobias/playpad/project/Project.java
index d6822079..dbf086b8 100644
--- a/PlayWallCore/src/main/java/de/tobias/playpad/project/Project.java
+++ b/PlayWallCore/src/main/java/de/tobias/playpad/project/Project.java
@@ -107,18 +107,15 @@ public class Project implements IProject {
 	}
 
 	public void setPad(PadIndex index, Pad pad) {
-		if (pad == null) {
-			return;
-		}
-		// Remove Pad from old location
-		if (pad.getPage().getPosition() != index.getPagePosition()) {
-			Page oldPage = pad.getPage();
+		// Remove Pad from old location if page changed
+		if (pad != null && pad.getPage().getPosition() != index.getPagePosition()) {
+			final Page oldPage = pad.getPage();
 			if (oldPage.getPad(pad.getPosition()).equals(pad)) {
 				oldPage.setPad(index.getId(), null);
 			}
 		}
 
-		Page page = pages.get(index.getPagePosition());
+		final Page page = pages.get(index.getPagePosition());
 		page.setPad(index.getId(), pad);
 	}
 
-- 
GitLab