From db8afe344ee076eec2a557f14437deeba559a2a0 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 12 May 2019 20:13:37 +0200 Subject: [PATCH] Caught an unexpected itemclass None, but can't recreate the bug. Added an extra check. --- nw/gui/doctree.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index 4ef921f2..d448dbd0 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -74,6 +74,9 @@ class GuiDocTree(QTreeWidget): logger.debug("DocTree initialisation complete") + # Internal Mapping + self.makeAlert = self.theParent.makeAlert + return ## @@ -89,8 +92,15 @@ class GuiDocTree(QTreeWidget): def newTreeItem(self, itemType, itemClass): pHandle = self.getSelectedHandle() - if itemClass is None and pHandle is not None: + if pHandle is None: + self.makeAlert("No valid parent item selected", 2) + return False + + if itemClass is None: itemClass = self.theProject.getItem(pHandle).itemClass + if itemClass is None: + self.makeAlert("Failed to find an appropriate item class for item %s" % pHandle, 2) + return False logger.verbose("Adding new item of type %s and class %s to handle %s" % ( itemType.name, itemClass.name, str(pHandle))