Qt: Fix some filename dialogs not checking for null return

This commit is contained in:
Vicki Pfau 2022-04-03 15:41:27 -07:00
parent e03b1486e4
commit a5c627c090
3 changed files with 9 additions and 1 deletions

View File

@ -577,6 +577,9 @@ void FrameView::frameCallback(FrameView* viewer, std::shared_ptr<bool> lock) {
void FrameView::exportFrame() {
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export frame"),
tr("Portable Network Graphics (*.png)"));
if (filename.isNull()) {
return;
}
CoreController::Interrupter interrupter(m_controller);
m_framebuffer.save(filename, "PNG");
}

View File

@ -86,7 +86,9 @@ void GIFView::stopRecording() {
void GIFView::selectFile() {
QString filename = GBAApp::app()->getSaveFileName(this, tr("Select output file"), tr("Graphics Interchange Format (*.gif);;WebP ( *.webp);;Animated Portable Network Graphics (*.png *.apng)"));
m_ui.filename->setText(filename);
if (!filename.isNull()) {
m_ui.filename->setText(filename);
}
}
void GIFView::setFilename(const QString& filename) {

View File

@ -136,6 +136,9 @@ void PaletteView::exportPalette(int start, int length) {
CoreController::Interrupter interrupter(m_controller);
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export palette"),
tr("Windows PAL (*.pal);;Adobe Color Table (*.act)"));
if (filename.isNull()) {
return;
}
VFile* vf = VFileDevice::open(filename, O_WRONLY | O_CREAT | O_TRUNC);
if (!vf) {
LOG(QT, ERROR) << tr("Failed to open output palette file: %1").arg(filename);