Fix static initialization order problem with Horus GUI (#4141)
* [480x272] Fix static initialization order problem with Layout, Theme, & Widget factories. * [480x272] Fix return from drawTimerMode(). * [480x272] Remove use of macros for registered Layout, Widget, & Theme class lists; remove extern declarations (cosmetic). * [480x272] Convert Layout and Theme registry to dynamic lists (still max. of 10 each); Hide indicator arrow when user is at start/end of available widgets in spinner UI; Add some sanity checking to pointer usage in screens_setup; Add an (arbitrary) limit of 20 Widgets; And a line break! :)
This commit is contained in:
committed by
Bertrand Songis
parent
d4d3d51a9d
commit
bce42bb25c
@@ -24,6 +24,20 @@ const BitmapBuffer * Theme::asterisk = NULL;
|
||||
const BitmapBuffer * Theme::question = NULL;
|
||||
const BitmapBuffer * Theme::busy = NULL;
|
||||
|
||||
std::list<Theme *> & getRegisteredThemes()
|
||||
{
|
||||
static std::list<Theme *> themes;
|
||||
return themes;
|
||||
}
|
||||
|
||||
void registerTheme(Theme * theme)
|
||||
{
|
||||
if (getRegisteredThemes().size() < MAX_REGISTERED_THEMES) {
|
||||
TRACE("register theme %s", theme->getName());
|
||||
getRegisteredThemes().push_back(theme);
|
||||
}
|
||||
}
|
||||
|
||||
void Theme::init() const
|
||||
{
|
||||
memset(&g_eeGeneral.themeData, 0, sizeof(Theme::PersistentData));
|
||||
@@ -112,22 +126,12 @@ void Theme::drawMessageBox(const char * title, const char * text, const char * a
|
||||
}
|
||||
}
|
||||
|
||||
Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic
|
||||
unsigned int countRegisteredThemes = 0;
|
||||
void registerTheme(Theme * theme)
|
||||
{
|
||||
if (countRegisteredThemes < MAX_REGISTERED_THEMES) {
|
||||
TRACE("register theme %s", theme->getName());
|
||||
registeredThemes[countRegisteredThemes++] = theme;
|
||||
}
|
||||
}
|
||||
|
||||
Theme * getTheme(const char * name)
|
||||
{
|
||||
for (unsigned int i=0; i<countRegisteredThemes; i++) {
|
||||
Theme * theme = registeredThemes[i];
|
||||
if (!strcmp(name, theme->getName())) {
|
||||
return theme;
|
||||
std::list<Theme *>::const_iterator it = getRegisteredThemes().cbegin();
|
||||
for (; it != getRegisteredThemes().cend(); ++it) {
|
||||
if (!strcmp(name, (*it)->getName())) {
|
||||
return (*it);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user