From 72292e01fc7d2e76d03df4c10f2f34b292638e0d Mon Sep 17 00:00:00 2001 From: Goldstein <32555045+EricGoldsteinNz@users.noreply.github.com> Date: Sat, 23 Sep 2023 15:04:46 +1200 Subject: [PATCH] Fix blank path and ROMs without covers causing a crash when trying to extract the ROM cover (#43) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: EricGoldsteinNz --- dialogs/ThumbnailDialog.py | 18 ++++++++++++------ tadpole.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dialogs/ThumbnailDialog.py b/dialogs/ThumbnailDialog.py index acb4e7d..830cff7 100644 --- a/dialogs/ThumbnailDialog.py +++ b/dialogs/ThumbnailDialog.py @@ -28,6 +28,13 @@ def __init__(self, filepath): self.current_viewer = ROMCoverViewer(self) self.layout_main.addWidget(self.current_viewer, Qt.AlignCenter) + # Load Initial Image + # If it's a supported .z**, open it, otherwise leave it blank + file_extension = file_extension = os.path.splitext(filepath)[1] + if file_extension == '.zfb' or file_extension == '.zfc' or file_extension == '.zgb' or \ + file_extension == '.zmd' or file_extension == '.zsf': + self.current_viewer.load_from_ROM_inMemory(filepath) + self.layout_main.addWidget(QLabel(" ")) # spacer # set up new image viewer @@ -42,6 +49,7 @@ def __init__(self, filepath): #Save Existing Cover To File Button self.button_write = QPushButton("Save Existing to File") self.button_write.clicked.connect(self.WriteImgToFile) + self.button_write.setDisabled(self.current_viewer.path == "") #Disable saving if the ROM has been detected as not currently having a cover self.layout_buttons.addWidget(self.button_write) # Save Button @@ -56,14 +64,12 @@ def __init__(self, filepath): self.button_cancel.clicked.connect(self.reject) self.layout_buttons.addWidget(self.button_cancel) - # Load Initial Image - # If it's a supported .z**, open it, otherwise leave it blank - file_extension = file_extension = os.path.splitext(filepath)[1] - if file_extension == '.zfb' or file_extension == '.zfc' or file_extension == '.zgb' or \ - file_extension == '.zmd' or file_extension == '.zsf': - self.current_viewer.load_from_ROM_inMemory(filepath) + def WriteImgToFile(self): + if self.current_viewer.path == "": + QMessageBox.warning(self, "Save ROM Cover", "This file was not detected as having a ROM cover.\n If you think this is an error please create an Issue on the Github repository.") + return newCoverFileName = QFileDialog.getSaveFileName(self, 'Save Cover', 'c:\\', diff --git a/tadpole.py b/tadpole.py index 08655ce..0299ae1 100644 --- a/tadpole.py +++ b/tadpole.py @@ -1089,7 +1089,7 @@ def UpdateDevice(self, url): def change_theme(self, url): qm = QMessageBox() - ret = qm.question(window,'Heads up', "Changing themes will ovewrite your game shortcut icons. You can change them again after the theme is applied. Are you suer you want to change your theme?" , qm.Yes | qm.No) + ret = qm.question(window,'Heads up', "Changing themes will ovewrite your game shortcut icons. You can change them again after the theme is applied. Are you sure you want to change your theme?" , qm.Yes | qm.No) if ret == qm.No: return drive = window.combobox_drive.currentText()