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