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:
Eduardo Bart
2012-03-22 18:47:52 -03:00
parent 159eb98df2
commit 33458a3e39
41 changed files with 335 additions and 234 deletions

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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
}