diff --git a/nw/core/project.py b/nw/core/project.py index 1bf53151..b077c53d 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -781,6 +781,10 @@ class NWProject(): def zipIt(self, doNotify): """Create a zip file of the entire project. """ + if not self.theParent.hasProject: + logger.error("No project open") + return False + logger.info("Backing up project") self.theParent.setStatus("Backing up project ...") diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 005c6ffa..8759d86e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -620,9 +620,10 @@ class GuiDocEditor(QTextEdit): this class when calling these actions from other classes. """ logger.verbose("Requesting action: %s" % theAction.name) - if not self.theParent.hasProject: - logger.error("No project open") + if self.theHandle is None: + logger.error("No document open") return False + self._allowAutoReplace(False) if theAction == nwDocAction.UNDO: self.undo() @@ -678,7 +679,9 @@ class GuiDocEditor(QTextEdit): logger.debug("Unknown or unsupported document action %s" % str(theAction)) self._allowAutoReplace(True) return False + self._allowAutoReplace(True) + return True def isEmpty(self): @@ -690,16 +693,20 @@ class GuiDocEditor(QTextEdit): """Tell the user where on the file system the file in the editor is saved. """ - if self.theHandle is not None: - msgBox = QMessageBox() - msgBox.information(self, "File Location", ( - "File details for the currently open file
" - "Handle: {handle:s}
" - "Location: {fileLoc:s}" - ).format( - handle = self.theHandle, - fileLoc = str(self.nwDocument.getFileLocation()) - )) + if self.theHandle is None: + logger.error("No document open") + return False + + msgBox = QMessageBox() + msgBox.information(self, "File Location", ( + "File details for the currently open file
" + "Handle: {handle:s}
" + "Location: {fileLoc:s}" + ).format( + handle = self.theHandle, + fileLoc = str(self.nwDocument.getFileLocation()) + )) + return def insertText(self, theInsert): diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index f0d0bca9..4116a863 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -163,6 +163,7 @@ class GuiProjectTree(QTreeWidget): nHandle = None if not self.theParent.hasProject: + logger.error("No project open") return False # The item needs to be assigned an item class, so one must be @@ -281,6 +282,10 @@ class GuiProjectTree(QTreeWidget): """Move an item up or down in the tree, but only if the treeView has focus. This also applies when the menu is used. """ + if not self.theParent.hasProject: + logger.error("No project open") + return False + hasFocus = qApp.focusWidget() == self or not self.mainConf.showGUI if hasFocus and self.theParent.hasProject: @@ -364,6 +369,10 @@ class GuiProjectTree(QTreeWidget): function only asks for confirmation once, and calls the regular deleteItem function for each document in the Trash folder. """ + if not self.theParent.hasProject: + logger.error("No project open") + return False + trashHandle = self.theProject.projTree.trashRoot() logger.debug("Emptying Trash folder") @@ -409,6 +418,10 @@ class GuiProjectTree(QTreeWidget): delete the files on disk. Folders are deleted if they're empty only, and the deletion is always permanent. """ + if not self.theParent.hasProject: + logger.error("No project open") + return False + if tHandle is None: tHandle = self.getSelectedHandle() diff --git a/nw/guimain.py b/nw/guimain.py index 574551c4..bfca4255 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1053,6 +1053,7 @@ class GuiMain(QMainWindow): """ if self.docEditor.theHandle is None: logger.error("No document open, so not activating Focus Mode") + self.mainMenu.aFocusMode.setChecked(self.isFocusMode) return False self.isFocusMode = not self.isFocusMode