Fixed memory leak: widget factories need to be deleted
in opentxClose()
This commit is contained in:
@@ -126,6 +126,8 @@ class WidgetFactory
|
||||
registerWidget(this);
|
||||
}
|
||||
|
||||
virtual ~WidgetFactory() {}
|
||||
|
||||
inline const char * getName() const
|
||||
{
|
||||
return name;
|
||||
|
||||
@@ -187,6 +187,9 @@ void registerBitmapClass(lua_State * L);
|
||||
void luaSetInstructionsLimit(lua_State* L, int count);
|
||||
int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * mode);
|
||||
|
||||
// Unregister LUA widget factories
|
||||
void luaUnregisterWidgets();
|
||||
|
||||
#if LCD_W > 350
|
||||
#define RADIO_TOOL_NAME_MAXLEN 40
|
||||
#else
|
||||
|
||||
@@ -512,3 +512,13 @@ void luaInitThemesAndWidgets()
|
||||
luaDoGc(lsWidgets, true);
|
||||
}
|
||||
}
|
||||
|
||||
void luaUnregisterWidgets()
|
||||
{
|
||||
std::list<const WidgetFactory *> regWidgets(getRegisteredWidgets());
|
||||
for (auto w : regWidgets) {
|
||||
if (dynamic_cast<const LuaWidgetFactory*>(w)) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1518,6 +1518,8 @@ void opentxClose(uint8_t shutdown)
|
||||
|
||||
//TODO: In fact we want only to empty the trash (private method)
|
||||
MainWindow::instance()->run();
|
||||
|
||||
luaUnregisterWidgets();
|
||||
luaClose(&lsWidgets);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user