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."""
|
"""Delete the currently selected build settings entry."""
|
||||||
if build := self._getSelectedBuild():
|
if build := self._getSelectedBuild():
|
||||||
if SHARED.question(self.tr("Delete build '{0}'?".format(build.name))):
|
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._builds.removeBuild(build.buildID)
|
||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
return
|
return
|
||||||
@@ -459,13 +461,9 @@ class GuiManuscript(NToolDialog):
|
|||||||
|
|
||||||
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
||||||
"""Open the build settings dialog."""
|
"""Open the build settings dialog."""
|
||||||
for obj in SHARED.mainGui.children():
|
if dialog := self._findSettingsDialog(build.buildID):
|
||||||
# Don't open a second dialog if one exists
|
dialog.activateDialog()
|
||||||
if isinstance(obj, GuiBuildSettings):
|
return
|
||||||
if obj.buildID == build.buildID:
|
|
||||||
logger.debug("Found instance of GuiBuildSettings")
|
|
||||||
obj.activateDialog()
|
|
||||||
return
|
|
||||||
|
|
||||||
dialog = GuiBuildSettings(SHARED.mainGui, build)
|
dialog = GuiBuildSettings(SHARED.mainGui, build)
|
||||||
dialog.activateDialog()
|
dialog.activateDialog()
|
||||||
@@ -495,6 +493,15 @@ class GuiManuscript(NToolDialog):
|
|||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
return
|
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
|
# END Class GuiManuscript
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,14 @@ def testManuscript_Builds(qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
|||||||
manus.show()
|
manus.show()
|
||||||
manus.loadContent()
|
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.clearSelection()
|
||||||
manus.buildList.setCurrentRow(0)
|
manus.buildList.setCurrentRow(0)
|
||||||
manus.tbDel.click()
|
manus.tbDel.click()
|
||||||
|
|||||||
Reference in New Issue
Block a user