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
@@ -20,19 +20,26 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
std::list<const WidgetFactory *> registeredWidgets;
|
||||
std::list<const WidgetFactory *> & getRegisteredWidgets()
|
||||
{
|
||||
static std::list<const WidgetFactory *> widgets;
|
||||
return widgets;
|
||||
}
|
||||
|
||||
void registerWidget(const WidgetFactory * factory)
|
||||
{
|
||||
TRACE("register widget %s", factory->getName());
|
||||
registeredWidgets.push_back(factory);
|
||||
if (getRegisteredWidgets().size() < MAX_REGISTERED_WIDGETS) {
|
||||
TRACE("register widget %s", factory->getName());
|
||||
getRegisteredWidgets().push_back(factory);
|
||||
}
|
||||
}
|
||||
|
||||
const WidgetFactory * getWidgetFactory(const char * name)
|
||||
{
|
||||
for (std::list<const WidgetFactory *>::iterator it = registeredWidgets.begin(); it != registeredWidgets.end();++it) {
|
||||
const WidgetFactory * factory = *it;
|
||||
if (!strcmp(name, factory->getName())) {
|
||||
return factory;
|
||||
std::list<const WidgetFactory *>::const_iterator it = getRegisteredWidgets().cbegin();
|
||||
for (; it != getRegisteredWidgets().cend();++it) {
|
||||
if (!strcmp(name, (*it)->getName())) {
|
||||
return (*it);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user