Make sure deleted documents are closed if open

This commit is contained in:
Veronica Berglyd Olsen
2024-11-21 22:24:34 +01:00
parent 7ed619cf2e
commit e0b27317f3
3 changed files with 8 additions and 2 deletions
+1
View File
@@ -174,6 +174,7 @@ class NWProject:
project entry and a document file if it exists. project entry and a document file if it exists.
""" """
if self._tree.checkType(tHandle, nwItemType.FILE): if self._tree.checkType(tHandle, nwItemType.FILE):
SHARED.closeDocument(tHandle)
doc = self._storage.getDocument(tHandle) doc = self._storage.getDocument(tHandle)
if not doc.deleteDocument(): if not doc.deleteDocument():
SHARED.error( SHARED.error(
+3 -1
View File
@@ -175,10 +175,12 @@ class SharedData(QObject):
logger.debug("Thread Pool Max Count: %d", QThreadPool.globalInstance().maxThreadCount()) logger.debug("Thread Pool Max Count: %d", QThreadPool.globalInstance().maxThreadCount())
return return
def closeEditor(self, tHandle: str | None = None) -> None: def closeDocument(self, tHandle: str | None = None) -> None:
"""Close the document editor, optionally a specific document.""" """Close the document editor, optionally a specific document."""
if tHandle is None or tHandle == self.mainGui.docEditor.docHandle: if tHandle is None or tHandle == self.mainGui.docEditor.docHandle:
self.mainGui.closeDocument() self.mainGui.closeDocument()
if tHandle is None or tHandle == self.mainGui.docViewer.docHandle:
self.mainGui.closeViewerPanel()
return return
def saveEditor(self, tHandle: str | None = None) -> None: def saveEditor(self, tHandle: str | None = None) -> None:
+4 -1
View File
@@ -20,7 +20,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
from __future__ import annotations from __future__ import annotations
from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtGui import QFont, QIcon, QPixmap
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget
@@ -68,6 +68,9 @@ class MockTheme:
def __init__(self): def __init__(self):
self.baseIconHeight = 20 self.baseIconHeight = 20
self.guiFont = QFont()
self.guiFontB = QFont()
self.guiFontBU = QFont()
return return
def getPixmap(self, *a): def getPixmap(self, *a):