From 64e9406488504b84a511ec354e3bc0e8774ed21b Mon Sep 17 00:00:00 2001 From: TheSumm Date: Tue, 27 Jan 2015 21:14:07 +0100 Subject: [PATCH] Fixed 'widget destroyed but still have 1 reference left' related to console module --- modules/corelib/ui/uimovabletabbar.lua | 37 +++++++++++++++++--------- modules/game_console/console.lua | 13 +++++++-- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/modules/corelib/ui/uimovabletabbar.lua b/modules/corelib/ui/uimovabletabbar.lua index 187a8c49..ad59df79 100644 --- a/modules/corelib/ui/uimovabletabbar.lua +++ b/modules/corelib/ui/uimovabletabbar.lua @@ -17,19 +17,19 @@ local function updateMargins(tabBar, ignored) end local function updateNavigation(tabBar) - if prevNavigation then + if tabBar.prevNavigation then if #tabBar.preTabs > 0 or table.find(tabBar.tabs, tabBar.currentTab) ~= 1 then - prevNavigation:enable() + tabBar.prevNavigation:enable() else - prevNavigation:disable() + tabBar.prevNavigation:disable() end end - if nextNavigation then + if tabBar.nextNavigation then if #tabBar.postTabs > 0 or table.find(tabBar.tabs, tabBar.currentTab) ~= #tabBar.tabs then - nextNavigation:enable() + tabBar.nextNavigation:enable() else - nextNavigation:disable() + tabBar.nextNavigation:disable() end end end @@ -218,6 +218,19 @@ function UIMoveableTabBar.create() return tabbar end +function UIMoveableTabBar:onDestroy() + if self.prevNavigation then + self.prevNavigation:disable() + end + + if self.nextNavigation then + self.nextNavigation:disable() + end + + self.nextNavigation = nil + self.prevNavigation = nil +end + function UIMoveableTabBar:setContentWidget(widget) self.contentWidget = widget if #self.tabs > 0 then @@ -467,14 +480,14 @@ function UIMoveableTabBar:getCurrentTab() end function UIMoveableTabBar:setNavigation(prevButton, nextButton) - prevNavigation = prevButton - nextNavigation = nextButton + self.prevNavigation = prevButton + self.nextNavigation = nextButton - if prevNavigation then - prevNavigation.onClick = function() self:selectPrevTab() end + if self.prevNavigation then + self.prevNavigation.onClick = function() self:selectPrevTab() end end - if nextNavigation then - nextNavigation.onClick = function() self:selectNextTab() end + if self.nextNavigation then + self.nextNavigation.onClick = function() self:selectNextTab() end end updateNavigation(self) end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index f19db151..ce9fce28 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -170,7 +170,7 @@ function enableChat() gameInterface.unbindWalkKey("D") gameInterface.unbindWalkKey("S") gameInterface.unbindWalkKey("A") - + gameInterface.unbindWalkKey("E") gameInterface.unbindWalkKey("Q") gameInterface.unbindWalkKey("C") @@ -199,7 +199,7 @@ function disableChat() gameInterface.bindWalkKey("D", East) gameInterface.bindWalkKey("S", South) gameInterface.bindWalkKey("A", West) - + gameInterface.bindWalkKey("E", NorthEast) gameInterface.bindWalkKey("Q", NorthWest) gameInterface.bindWalkKey("C", SouthEast) @@ -245,7 +245,13 @@ function terminate() violationWindow:destroy() end + consoleTabBar = nil + consoleContentPanel = nil + consoleToggleChat = nil + consoleTextEdit = nil + consolePanel:destroy() + consolePanel = nil ownPrivateName = nil Console = nil @@ -300,11 +306,14 @@ function clear() channels = {} consoleTabBar:removeTab(defaultTab) + defaultTab = nil consoleTabBar:removeTab(serverTab) + serverTab = nil local npcTab = consoleTabBar:getTab('NPCs') if npcTab then consoleTabBar:removeTab(npcTab) + npcTab = nil end if violationReportTab then