Unregister LUA widgets when the factory is destoyed

Resolves #183
This commit is contained in:
Raphael Coeffic
2021-06-12 07:38:30 +02:00
parent 4e1427c4a7
commit c37bc91475
3 changed files with 12 additions and 0 deletions
+6
View File
@@ -196,6 +196,12 @@ void registerWidget(const WidgetFactory * factory)
getRegisteredWidgets().push_back(factory);
}
void unregisterWidget(const WidgetFactory * factory)
{
TRACE("unregister widget %s", factory->getName());
getRegisteredWidgets().remove(factory);
}
const WidgetFactory * getWidgetFactory(const char * name)
{
auto it = getRegisteredWidgets().cbegin();
+1
View File
@@ -114,6 +114,7 @@ class Widget : public Button
};
void registerWidget(const WidgetFactory * factory);
void unregisterWidget(const WidgetFactory * factory);
class WidgetFactory
{
+5
View File
@@ -225,6 +225,11 @@ class LuaWidgetFactory: public WidgetFactory
{
}
~LuaWidgetFactory()
{
unregisterWidget(this);
}
Widget * create(FormGroup * parent, const rect_t & rect, Widget::PersistentData * persistentData, bool init=true) const override
{
if (lsWidgets == 0) return 0;