Skip to content

Commit

Permalink
Fix blank path and ROMs without covers causing a crash when trying to…
Browse files Browse the repository at this point in the history
… extract the ROM cover (#43)

Co-authored-by: EricGoldsteinNz <EricGoldsteinNz���@users.noreply.github.com>
  • Loading branch information
EricGoldsteinNz and EricGoldsteinNz authored Sep 23, 2023
1 parent e56b734 commit 72292e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions dialogs/ThumbnailDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:\\',
Expand Down
2 changes: 1 addition & 1 deletion tadpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 72292e0

Please sign in to comment.