From 25bbd0eeca461fb5d501854c14ecec797603d8cc Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Thu, 7 Jul 2022 13:55:26 +0200 Subject: clean up the clean-up logic --- .../main/java/at/asit/pdfover/gui/workflow/Status.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java index 3b03de78..3920b4d7 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java @@ -57,21 +57,18 @@ public class Status { return this.currentState; } - public void setCurrentState(State currentState) { - log.debug("Changing from " + this.currentState + " to " + currentState); + public void setCurrentState(State newState) { + log.debug("Changing from " + currentState + " to " + newState); - if (this.previousState != this.currentState) + if ((previousState != null) && (previousState != currentState) && (previousState != newState)) { // Reference to previous state will be lost - perform cleanup - if (this.previousState != null) - { - log.debug("Cleaning up " + this.previousState); - this.previousState.cleanUp(); - } + log.debug("Cleaning up " + previousState); + previousState.cleanUp(); } - this.previousState = this.currentState; - this.currentState = currentState; + this.previousState = currentState; + this.currentState = newState; } public State getPreviousState() { -- cgit v1.2.3