From 7867965989c6fbba670d57e76404018ac7e6bb17 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 2 May 2021 17:19:50 +0200 Subject: [PATCH] Alter the init logic of handles in NWDoc --- nw/core/document.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nw/core/document.py b/nw/core/document.py index 956dee5d..7088f61a 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -39,13 +39,16 @@ class NWDoc(): self.theProject = theProject # Internal Variables - self._docHandle = theHandle - self._theItem = None - self._fileLoc = None - self._docMeta = {} - self._docError = "" + self._theItem = None # The currently open item + self._docHandle = None # The handle of the currently open item + self._fileLoc = None # The file location of the currently open item + self._docMeta = {} # The meta data of the currently open item + self._docError = "" # The latest encountered IO error - if theHandle is not None: + if isHandle(theHandle): + self._docHandle = theHandle + + if self._docHandle is not None: self._theItem = self.theProject.projTree[theHandle] return @@ -61,7 +64,7 @@ class NWDoc(): None. """ self._docError = "" - if not isHandle(self._docHandle): + if self._docHandle is None: logger.error("No document handle set") return None @@ -110,7 +113,7 @@ class NWDoc(): of save failure. Returns True if successful, False if not. """ self._docError = "" - if not isHandle(self._docHandle): + if self._docHandle is None: logger.error("No document handle set") return False @@ -153,7 +156,7 @@ class NWDoc(): from the project data folder. """ self._docError = "" - if not isHandle(self._docHandle): + if self._docHandle is None: logger.error("No document handle set") return False