Make sure build settings are closed before deletion
This commit is contained in:
@@ -311,6 +311,8 @@ class GuiManuscript(NToolDialog):
|
||||
"""Delete the currently selected build settings entry."""
|
||||
if build := self._getSelectedBuild():
|
||||
if SHARED.question(self.tr("Delete build '{0}'?".format(build.name))):
|
||||
if dialog := self._findSettingsDialog(build.buildID):
|
||||
dialog.close()
|
||||
self._builds.removeBuild(build.buildID)
|
||||
self._updateBuildsList()
|
||||
return
|
||||
@@ -459,13 +461,9 @@ class GuiManuscript(NToolDialog):
|
||||
|
||||
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
||||
"""Open the build settings dialog."""
|
||||
for obj in SHARED.mainGui.children():
|
||||
# Don't open a second dialog if one exists
|
||||
if isinstance(obj, GuiBuildSettings):
|
||||
if obj.buildID == build.buildID:
|
||||
logger.debug("Found instance of GuiBuildSettings")
|
||||
obj.activateDialog()
|
||||
return
|
||||
if dialog := self._findSettingsDialog(build.buildID):
|
||||
dialog.activateDialog()
|
||||
return
|
||||
|
||||
dialog = GuiBuildSettings(SHARED.mainGui, build)
|
||||
dialog.activateDialog()
|
||||
@@ -495,6 +493,15 @@ class GuiManuscript(NToolDialog):
|
||||
self._updateBuildsList()
|
||||
return
|
||||
|
||||
def _findSettingsDialog(self, buildID: str) -> GuiBuildSettings | None:
|
||||
"""Return an open build settings dialog for a given build, if
|
||||
one exists.
|
||||
"""
|
||||
for obj in SHARED.mainGui.children():
|
||||
if isinstance(obj, GuiBuildSettings) and obj.buildID == buildID:
|
||||
return obj
|
||||
return None
|
||||
|
||||
# END Class GuiManuscript
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,14 @@ def testManuscript_Builds(qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
||||
manus.show()
|
||||
manus.loadContent()
|
||||
|
||||
# Delete the default build
|
||||
# Delete the default build, while it is open
|
||||
manus.buildList.clearSelection()
|
||||
manus.buildList.setCurrentRow(0)
|
||||
with qtbot.waitSignal(manus.tbEdit.clicked, timeout=5000):
|
||||
manus.tbEdit.click()
|
||||
|
||||
manus._editSelectedBuild()
|
||||
|
||||
manus.buildList.clearSelection()
|
||||
manus.buildList.setCurrentRow(0)
|
||||
manus.tbDel.click()
|
||||
|
||||
Reference in New Issue
Block a user