mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-13 10:13:47 +00:00
Fix crash setting theme in certain cases
Mainly when changing ui::View children (where a view changes its children onInitTheme() function, e.g. adding/removing scrollbar).
This commit is contained in:
parent
722ca13b8e
commit
a4fc3735c7
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -58,10 +58,22 @@ void reinitThemeForAllWidgets()
|
||||
{
|
||||
assert_ui_thread();
|
||||
|
||||
// Reinitialize the theme of each widget
|
||||
// Reinitialize the theme in this order:
|
||||
// 1. From the manager to children (windows and children widgets in
|
||||
// the window etc.)
|
||||
auto theme = get_theme();
|
||||
for (auto widget : *widgets)
|
||||
widget->setTheme(theme);
|
||||
if (auto man = Manager::getDefault()) {
|
||||
man->setTheme(theme);
|
||||
}
|
||||
|
||||
// 2. If some other widget wasn't updated (e.g. is outside the
|
||||
// hierarchy of widgets), we update the theme for that one too.
|
||||
//
|
||||
// TODO Is this really needed?
|
||||
for (auto widget : *widgets) {
|
||||
if (theme != widget->theme())
|
||||
widget->setTheme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace details
|
||||
|
Loading…
x
Reference in New Issue
Block a user