From 3486dcca7ee6d963136cf660ba442c0cf27a7f93 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 23 Nov 2023 09:47:12 -0300 Subject: [PATCH] Add minor comment in DocExporter::createEmptyTexture() (#4127, #4135) --- src/app/doc_exporter.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/doc_exporter.cpp b/src/app/doc_exporter.cpp index 57e79bdcf..9eb62541a 100644 --- a/src/app/doc_exporter.cpp +++ b/src/app/doc_exporter.cpp @@ -1185,13 +1185,18 @@ Doc* DocExporter::createEmptyTexture(const Samples& samples, int maxColors = 256; gfx::ColorSpaceRef colorSpace; color_t transparentColor = 0; - bool ui = false; -#ifdef ENABLE_UI - if (App::instance()->isGui()) - ui = true; -#endif + + // We generate a palette for file formats that support a color + // palette inside, or if the UI/preview is available/required. + // + // As a side note, here we cannot use a possible + // ctx->isUIAvailable() (instead of App::instance()->isGui()) + // because when the sprite sheet is generated from the UI, a + // temporal non-UI context is created in a background thread. + const bool paletteRequiredByUIPreview = App::instance()->isGui(); const bool textureSupportsPalette = - format_supports_palette(m_textureFilename) || ui; + format_supports_palette(m_textureFilename) || + paletteRequiredByUIPreview; for (const auto& sample : samples) { if (token.canceled())