Fix market reload and a crash when exiting

This commit is contained in:
Eduardo Bart 2012-07-31 11:42:26 -03:00
parent bca1af8f11
commit 614d1544c0
13 changed files with 15 additions and 23 deletions

View File

@ -128,6 +128,7 @@ function initProtocol()
-- reloading module -- reloading module
if g_game.isOnline() then if g_game.isOnline() then
MarketProtocol.registerProtocol()
MarketProtocol.updateProtocol(g_game.getProtocolGame()) MarketProtocol.updateProtocol(g_game.getProtocolGame())
end end
end end
@ -139,6 +140,7 @@ function terminateProtocol()
-- reloading module -- reloading module
if not g_game.isOnline() then if not g_game.isOnline() then
MarketProtocol.updateProtocol(nil) MarketProtocol.updateProtocol(nil)
MarketProtocol.unregisterProtocol()
end end
MarketProtocol = nil MarketProtocol = nil
end end

View File

@ -38,11 +38,10 @@ FileStream::FileStream(const std::string& name, PHYSFS_File *fileHandle, bool wr
FileStream::~FileStream() FileStream::~FileStream()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("FileStream reference not released");
#endif #endif
if(!g_app.isTerminated()) if(!g_app.isTerminated())
close(); close();
} }
void FileStream::cache() void FileStream::cache()

View File

@ -48,8 +48,7 @@ void FrameBuffer::internalCreate()
FrameBuffer::~FrameBuffer() FrameBuffer::~FrameBuffer()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("FrameBuffer reference not released");
#endif #endif
if(g_graphics.ok() && m_fbo != 0) if(g_graphics.ok() && m_fbo != 0)
glDeleteFramebuffers(1, &m_fbo); glDeleteFramebuffers(1, &m_fbo);

View File

@ -38,8 +38,7 @@ HardwareBuffer::HardwareBuffer(Type type)
HardwareBuffer::~HardwareBuffer() HardwareBuffer::~HardwareBuffer()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("HardwareBuffer reference not released");
#endif #endif
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteBuffers(1, &m_id); glDeleteBuffers(1, &m_id);

View File

@ -45,8 +45,7 @@ Shader::Shader(Shader::ShaderType shaderType)
Shader::~Shader() Shader::~Shader()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("Shader reference not released");
#endif #endif
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteShader(m_shaderId); glDeleteShader(m_shaderId);

View File

@ -39,8 +39,7 @@ ShaderProgram::ShaderProgram()
ShaderProgram::~ShaderProgram() ShaderProgram::~ShaderProgram()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("ShaderProgram reference not released");
#endif #endif
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteProgram(m_programId); glDeleteProgram(m_programId);

View File

@ -80,8 +80,7 @@ Texture::Texture(const ImagePtr& image, bool buildMipmaps)
Texture::~Texture() Texture::~Texture()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("a texture reference was not released");
#endif #endif
// free texture from gl memory // free texture from gl memory
if(g_graphics.ok() && m_id != 0) if(g_graphics.ok() && m_id != 0)

View File

@ -34,8 +34,7 @@ LuaObject::LuaObject() :
LuaObject::~LuaObject() LuaObject::~LuaObject()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("LuaObject reference not released");
#endif #endif
releaseLuaFieldsTable(); releaseLuaFieldsTable();

View File

@ -42,8 +42,7 @@ Connection::Connection() :
Connection::~Connection() Connection::~Connection()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("Connection reference not released");
#endif #endif
close(); close();
} }

View File

@ -34,8 +34,7 @@ Protocol::Protocol()
Protocol::~Protocol() Protocol::~Protocol()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("Protocol reference not released");
#endif #endif
disconnect(); disconnect();
} }

View File

@ -47,8 +47,7 @@ UIWidget::UIWidget()
UIWidget::~UIWidget() UIWidget::~UIWidget()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning(stdext::format("UIWidget '%s' reference not released", m_id));
if(!m_destroyed) if(!m_destroyed)
g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id)); g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id));
#endif #endif

View File

@ -65,8 +65,7 @@ MapView::MapView()
MapView::~MapView() MapView::~MapView()
{ {
#ifndef NDEBUG #ifndef NDEBUG
if(g_app.isTerminated()) assert(!g_app.isTerminated());
g_logger.warning("MapView reference not released");
#endif #endif
} }

View File

@ -79,6 +79,7 @@ void OTClient::init(const std::vector<std::string>& args)
void OTClient::terminate() void OTClient::terminate()
{ {
g_game.terminate();
g_map.terminate(); g_map.terminate();
g_things.terminate(); g_things.terminate();
g_sprites.terminate(); g_sprites.terminate();