mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
modules changes
* speedup widget destruction checks * rework outfit module using grid layout and the new design * fixes in console, terminal, textmessage modules
This commit is contained in:
@@ -225,6 +225,31 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
|
||||
updateDraggingWidget(nullptr);
|
||||
}
|
||||
|
||||
void UIManager::addDestroyedWidget(const UIWidgetPtr& widget)
|
||||
{
|
||||
static UIWidgetList destroyedWidgets;
|
||||
static ScheduledEventPtr checkEvent;
|
||||
|
||||
if(widget == m_rootWidget)
|
||||
return;
|
||||
|
||||
destroyedWidgets.push_back(widget);
|
||||
|
||||
if(checkEvent && !checkEvent->isExecuted())
|
||||
return;
|
||||
|
||||
checkEvent = g_eventDispatcher.scheduleEvent([] {
|
||||
g_lua.collectGarbage();
|
||||
g_eventDispatcher.addEvent([] {
|
||||
g_lua.collectGarbage();
|
||||
for(const UIWidgetPtr& widget : destroyedWidgets) {
|
||||
if(widget->getUseCount() != 1)
|
||||
logWarning("widget '", widget->getId(), "' destroyed but still have ", widget->getUseCount()-1, " reference(s) left");
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
bool UIManager::importStyle(const std::string& file)
|
||||
{
|
||||
try {
|
||||
|
@@ -68,6 +68,7 @@ protected:
|
||||
void onWidgetAppear(const UIWidgetPtr& widget);
|
||||
void onWidgetDisappear(const UIWidgetPtr& widget);
|
||||
void onWidgetDestroy(const UIWidgetPtr& widget);
|
||||
void addDestroyedWidget(const UIWidgetPtr& widget);
|
||||
|
||||
friend class UIWidget;
|
||||
|
||||
|
@@ -636,10 +636,8 @@ void UIWidget::destroy()
|
||||
g_ui.onWidgetDestroy(asUIWidget());
|
||||
|
||||
// remove itself from parent
|
||||
if(UIWidgetPtr parent = getParent()) {
|
||||
assert(parent->hasChild(asUIWidget()));
|
||||
if(UIWidgetPtr parent = getParent())
|
||||
parent->removeChild(asUIWidget());
|
||||
}
|
||||
|
||||
destroyChildren();
|
||||
m_focusedChild = nullptr;
|
||||
@@ -649,15 +647,7 @@ void UIWidget::destroy()
|
||||
releaseLuaFieldsTable();
|
||||
|
||||
#ifdef DEBUG
|
||||
auto self = asUIWidget();
|
||||
g_lua.collectGarbage();
|
||||
if(self != g_ui.getRootWidget()) {
|
||||
g_eventDispatcher.scheduleEvent([self] {
|
||||
g_lua.collectGarbage();
|
||||
if(self->getUseCount() != 1)
|
||||
logWarning("widget '", self->getId(), "' destroyed but still have ", self->getUseCount()-1, " reference(s) left");
|
||||
}, 500);
|
||||
}
|
||||
g_ui.addDestroyedWidget(asUIWidget());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user