Alter the init logic of handles in NWDoc

This commit is contained in:
Veronica K. B. Olsen
2021-05-02 17:19:50 +02:00
parent 348513a248
commit 7867965989
+12 -9
View File
@@ -39,13 +39,16 @@ class NWDoc():
self.theProject = theProject self.theProject = theProject
# Internal Variables # Internal Variables
self._docHandle = theHandle self._theItem = None # The currently open item
self._theItem = None self._docHandle = None # The handle of the currently open item
self._fileLoc = None self._fileLoc = None # The file location of the currently open item
self._docMeta = {} self._docMeta = {} # The meta data of the currently open item
self._docError = "" 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] self._theItem = self.theProject.projTree[theHandle]
return return
@@ -61,7 +64,7 @@ class NWDoc():
None. None.
""" """
self._docError = "" self._docError = ""
if not isHandle(self._docHandle): if self._docHandle is None:
logger.error("No document handle set") logger.error("No document handle set")
return None return None
@@ -110,7 +113,7 @@ class NWDoc():
of save failure. Returns True if successful, False if not. of save failure. Returns True if successful, False if not.
""" """
self._docError = "" self._docError = ""
if not isHandle(self._docHandle): if self._docHandle is None:
logger.error("No document handle set") logger.error("No document handle set")
return False return False
@@ -153,7 +156,7 @@ class NWDoc():
from the project data folder. from the project data folder.
""" """
self._docError = "" self._docError = ""
if not isHandle(self._docHandle): if self._docHandle is None:
logger.error("No document handle set") logger.error("No document handle set")
return False return False