From 67bbb224105c37532bb57c1652cbcc5210f5d097 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 31 May 2016 15:07:26 -0300 Subject: [PATCH] Delete temporal tags created in the CLI processor When a DocumentExporter is used to export a specific range of frames from the CLI processor, a temporal frame tag is created, we've to delete that tag when the DocumentExporter is destroyed. --- src/app/cli/cli_processor.cpp | 9 ++++++--- src/app/document_exporter.cpp | 8 ++++++++ src/app/document_exporter.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/cli/cli_processor.cpp b/src/app/cli/cli_processor.cpp index 00555dc9e..807c263de 100644 --- a/src/app/cli/cli_processor.cpp +++ b/src/app/cli/cli_processor.cpp @@ -307,6 +307,8 @@ bool CliProcessor::openFile(CliOpenFile& cof) // Add document to exporter if (m_exporter) { FrameTag* frameTag = nullptr; + bool isTemporalTag = false; + if (!cof.frameTagName.empty()) { frameTag = doc->sprite()->frameTags().getByName(cof.frameTagName); } @@ -320,6 +322,7 @@ bool CliProcessor::openFile(CliOpenFile& cof) frameTag = new FrameTag(base::convert_to(splitRange[0]), base::convert_to(splitRange[1])); + isTemporalTag = true; } if (!cof.importLayer.empty()) { @@ -331,16 +334,16 @@ bool CliProcessor::openFile(CliOpenFile& cof) } } if (foundLayer) - m_exporter->addDocument(doc, foundLayer, frameTag); + m_exporter->addDocument(doc, foundLayer, frameTag, isTemporalTag); } else if (cof.splitLayers) { for (auto layer : doc->sprite()->layers()) { if (layer->isVisible()) - m_exporter->addDocument(doc, layer, frameTag); + m_exporter->addDocument(doc, layer, frameTag, isTemporalTag); } } else { - m_exporter->addDocument(doc, nullptr, frameTag); + m_exporter->addDocument(doc, nullptr, frameTag, isTemporalTag); } } } diff --git a/src/app/document_exporter.cpp b/src/app/document_exporter.cpp index 5f06810a5..9e8afdd55 100644 --- a/src/app/document_exporter.cpp +++ b/src/app/document_exporter.cpp @@ -354,6 +354,14 @@ DocumentExporter::DocumentExporter() { } +DocumentExporter::~DocumentExporter() +{ + for (auto& item : m_documents) { + if (item.temporalTag) + delete item.frameTag; + } +} + Document* DocumentExporter::exportSheet() { // We output the metadata to std::cout if the user didn't specify a file. diff --git a/src/app/document_exporter.h b/src/app/document_exporter.h index a3305fc7f..46ca3769f 100644 --- a/src/app/document_exporter.h +++ b/src/app/document_exporter.h @@ -36,6 +36,7 @@ namespace app { }; DocumentExporter(); + ~DocumentExporter(); DataFormat dataFormat() const { return m_dataFormat; } const std::string& dataFilename() { return m_dataFilename; }