From 1d8f8566c51ddd7b5f0a0c3caccd46af80c13017 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 29 Mar 2020 13:31:19 -0500 Subject: [PATCH] [nostalgia/core/studio] Fix ng export to only attempt export if output file is given --- src/nostalgia/core/studio/tilesheeteditor.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/nostalgia/core/studio/tilesheeteditor.cpp b/src/nostalgia/core/studio/tilesheeteditor.cpp index 1712b71b..cf63d179 100644 --- a/src/nostalgia/core/studio/tilesheeteditor.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor.cpp @@ -461,26 +461,28 @@ TileSheetEditor::~TileSheetEditor() { saveState(); } -QString TileSheetEditor::itemName() { +QString TileSheetEditor::itemName() const { return m_itemName; } void TileSheetEditor::exportFile() { auto path = QFileDialog::getSaveFileName(this, tr("Export to Image"), "", tr("PNG (*.png)")); - auto ng = m_sheetData.toNostalgiaGraphic(); - QString palPath; - if (palPath == "" && ng->defaultPalette.type() == ox::FileAddressType::Path) { - palPath = ng->defaultPalette.getPath().value; + if (path != "") { + auto ng = m_sheetData.toNostalgiaGraphic(); + QString palPath; + if (palPath == "" && ng->defaultPalette.type() == ox::FileAddressType::Path) { + palPath = ng->defaultPalette.getPath().value; + } + std::unique_ptr npal; + try { + npal = m_ctx->project->loadObj(palPath); + } catch (ox::Error) { + qWarning() << "Could not open palette" << palPath; + // TODO: message box to notify of failure + } + toQImage(ng.get(), npal.get()).save(path, "PNG"); } - std::unique_ptr npal; - try { - npal = m_ctx->project->loadObj(palPath); - } catch (ox::Error) { - qWarning() << "Could not open palette" << palPath; - // TODO: message box to notify of failure - } - toQImage(ng.get(), npal.get()).save(path, "PNG"); } void TileSheetEditor::saveItem() {