Just use g_configs.unload(config) to unload config files.

Avoids concurrent modification errors.
This commit is contained in:
BenDol 2014-04-06 15:29:02 +12:00
parent a02c091376
commit 1baad726ae
5 changed files with 6 additions and 4 deletions

View File

@ -157,6 +157,7 @@ function table.tostring(t)
local maxn = #t local maxn = #t
local str = "" local str = ""
for k,v in pairs(t) do for k,v in pairs(t) do
v = tostring(v)
if k == maxn and k ~= 1 then if k == maxn and k ~= 1 then
str = str .. " and " .. v str = str .. " and " .. v
elseif maxn > 1 and k ~= 1 then elseif maxn > 1 and k ~= 1 then

View File

@ -783,8 +783,10 @@ function setupViewMode(mode)
gameRootPanel:fill('parent') gameRootPanel:fill('parent')
gameLeftPanel:setImageColor('alpha') gameLeftPanel:setImageColor('alpha')
gameRightPanel:setImageColor('alpha') gameRightPanel:setImageColor('alpha')
gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu():getHeight() - gameLeftPanel:getPaddingTop()) gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu()
gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu():getHeight() - gameRightPanel:getPaddingTop()) :getHeight() - gameLeftPanel:getPaddingTop())
gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu()
:getHeight() - gameRightPanel:getPaddingTop())
gameLeftPanel:setOn(true) gameLeftPanel:setOn(true)
gameLeftPanel:setVisible(true) gameLeftPanel:setVisible(true)
gameRightPanel:setOn(true) gameRightPanel:setOn(true)

View File

@ -55,7 +55,6 @@ bool Config::unload()
if(isLoaded()) { if(isLoaded()) {
m_confsDoc = nullptr; m_confsDoc = nullptr;
m_fileName = ""; m_fileName = "";
g_configs.remove(this);
return true; return true;
} }
return false; return false;

View File

@ -117,6 +117,7 @@ bool ConfigManager::unload(const std::string& file)
ConfigPtr config = get(file); ConfigPtr config = get(file);
if(config) { if(config) {
config->unload(); config->unload();
remove(config);
config = nullptr; config = nullptr;
return true; return true;
} }

View File

@ -197,7 +197,6 @@ void Application::registerLuaFunctions()
// Config // Config
g_lua.registerClass<Config>(); g_lua.registerClass<Config>();
g_lua.bindClassMemberFunction<Config>("save", &Config::save); g_lua.bindClassMemberFunction<Config>("save", &Config::save);
g_lua.bindClassMemberFunction<Config>("unload", &Config::unload);
g_lua.bindClassMemberFunction<Config>("setValue", &Config::setValue); g_lua.bindClassMemberFunction<Config>("setValue", &Config::setValue);
g_lua.bindClassMemberFunction<Config>("setList", &Config::setList); g_lua.bindClassMemberFunction<Config>("setList", &Config::setList);
g_lua.bindClassMemberFunction<Config>("getValue", &Config::getValue); g_lua.bindClassMemberFunction<Config>("getValue", &Config::getValue);