Fix crash (and show error message) when default font is nullptr (fix #5208)
build / build (Debug, macos-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, macos-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, noscripts, cli) (push) Waiting to run Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Waiting to run Details

Probably an edge-case for users that are creating new themes.
This commit is contained in:
David Capello 2025-06-10 22:02:12 -03:00
parent 2be4dc1474
commit 2bc4f0582d
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2018-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -48,9 +48,12 @@ public:
// When the main window is closed, we should close the console (in
// other case the main message loop will continue running for the
// console too).
m_mainWindowClosedConn = App::instance()->mainWindow()->Close.connect(
[this] { closeWindow(nullptr); });
// console too). The main window can be nullptr if the console is
// used to show an error when loading the default theme or font at
// the initialization.
if (auto* mainWin = App::instance()->mainWindow()) {
m_mainWindowClosedConn = mainWin->Close.connect([this] { closeWindow(nullptr); });
}
// When the window is closed, we clear the text
Close.connect([this] {

View File

@ -545,6 +545,13 @@ void SkinTheme::loadXml(BackwardCompatibility* backward)
text::FontRef font = fontData->getFont(m_fontMgr, size * ui::guiscale());
// No font?
if (font == nullptr) {
LOG(ERROR, "THEME: Error loading font for theme %s\n", idStr);
xmlFont = xmlFont->NextSiblingElement();
continue;
}
// SpriteSheetFonts have a default preferred size.
if (size == 0.0f && font->defaultSize() > 0.0f) {
size = font->defaultSize();