mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Implement message modes for 9.6
Fix possible crash when closing otclient Fix private messages Fix messages in 9.6
This commit is contained in:
@@ -97,6 +97,9 @@ void Application::deinit()
|
||||
|
||||
// poll remaining events
|
||||
poll();
|
||||
|
||||
// disable dispatcher events
|
||||
g_dispatcher.shutdown();
|
||||
}
|
||||
|
||||
void Application::terminate()
|
||||
@@ -115,9 +118,6 @@ void Application::terminate()
|
||||
// terminate script environment
|
||||
g_lua.terminate();
|
||||
|
||||
// flush remaining dispatcher events
|
||||
g_dispatcher.flush();
|
||||
|
||||
m_terminated = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
EventDispatcher g_dispatcher;
|
||||
|
||||
void EventDispatcher::flush()
|
||||
void EventDispatcher::shutdown()
|
||||
{
|
||||
while(!m_eventList.empty())
|
||||
poll();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
class EventDispatcher
|
||||
{
|
||||
public:
|
||||
void flush();
|
||||
void shutdown();
|
||||
void poll();
|
||||
|
||||
EventPtr addEvent(const std::function<void()>& callback, bool pushFront = false);
|
||||
|
||||
@@ -37,7 +37,11 @@ FileStream::FileStream(const std::string& name, PHYSFS_File *fileHandle, bool wr
|
||||
|
||||
FileStream::~FileStream()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("FileStream reference not released");
|
||||
#endif
|
||||
if(!g_app.isTerminated())
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -63,7 +67,7 @@ void FileStream::cache()
|
||||
|
||||
void FileStream::close()
|
||||
{
|
||||
if(m_fileHandle) {
|
||||
if(m_fileHandle && PHYSFS_isInit()) {
|
||||
if(!PHYSFS_close(m_fileHandle))
|
||||
throwError("close failed", true);
|
||||
m_fileHandle = nullptr;
|
||||
|
||||
@@ -47,7 +47,10 @@ void FrameBuffer::internalCreate()
|
||||
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("FrameBuffer reference not released");
|
||||
#endif
|
||||
if(g_graphics.ok() && m_fbo != 0)
|
||||
glDeleteFramebuffers(1, &m_fbo);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ HardwareBuffer::HardwareBuffer(Type type)
|
||||
|
||||
HardwareBuffer::~HardwareBuffer()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("HardwareBuffer reference not released");
|
||||
#endif
|
||||
if(g_graphics.ok())
|
||||
glDeleteBuffers(1, &m_id);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,10 @@ Shader::Shader(Shader::ShaderType shaderType)
|
||||
|
||||
Shader::~Shader()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("Shader reference not released");
|
||||
#endif
|
||||
if(g_graphics.ok())
|
||||
glDeleteShader(m_shaderId);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,10 @@ ShaderProgram::ShaderProgram()
|
||||
|
||||
ShaderProgram::~ShaderProgram()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("ShaderProgram reference not released");
|
||||
#endif
|
||||
if(g_graphics.ok())
|
||||
glDeleteProgram(m_programId);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ Texture::Texture(const ImagePtr& image, bool buildMipmaps)
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("a texture reference was not released");
|
||||
#endif
|
||||
// free texture from gl memory
|
||||
if(g_graphics.ok() && m_id != 0)
|
||||
glDeleteTextures(1, &m_id);
|
||||
|
||||
@@ -37,18 +37,6 @@ void TextureManager::init()
|
||||
|
||||
void TextureManager::terminate()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// check for leaks
|
||||
int refs = 0;
|
||||
for(const auto& it : m_textures) {
|
||||
if(it.second->ref_count() > 1) {
|
||||
refs++;
|
||||
g_logger.debug(stdext::format("texture reference released: %s", it.first));
|
||||
}
|
||||
}
|
||||
if(refs > 0)
|
||||
g_logger.debug(stdext::format("%d textures references left", refs));
|
||||
#endif
|
||||
m_textures.clear();
|
||||
m_emptyTexture = nullptr;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@ LuaObject::LuaObject() :
|
||||
|
||||
LuaObject::~LuaObject()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("LuaObject reference not released");
|
||||
#endif
|
||||
releaseLuaFieldsTable();
|
||||
|
||||
if(m_metatableRef != -1) {
|
||||
|
||||
@@ -41,7 +41,10 @@ Connection::Connection() :
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("Connection reference not released");
|
||||
#endif
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,10 @@ Protocol::Protocol()
|
||||
|
||||
Protocol::~Protocol()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning("Protocol reference not released");
|
||||
#endif
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ private:
|
||||
std::unordered_map<std::string, OTMLNodePtr> m_styles;
|
||||
UIWidgetList m_destroyedWidgets;
|
||||
ScheduledEventPtr m_checkEvent;
|
||||
|
||||
};
|
||||
|
||||
extern UIManager g_ui;
|
||||
|
||||
@@ -46,8 +46,9 @@ UIWidget::UIWidget()
|
||||
|
||||
UIWidget::~UIWidget()
|
||||
{
|
||||
assert(!g_app.isTerminated());
|
||||
#ifndef NDEBUG
|
||||
if(g_app.isTerminated())
|
||||
g_logger.warning(stdext::format("UIWidget '%s' reference not released", m_id));
|
||||
if(!m_destroyed)
|
||||
g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user