From 746ef7cbd692af74faeefdbb0e45e8ab5b1b11d4 Mon Sep 17 00:00:00 2001 From: Phobos Tro Date: Sun, 25 Oct 2015 22:15:56 +0800 Subject: Fixing memory leaks --- platform/x11/context_gl_x11.cpp | 10 ++++++++-- platform/x11/os_x11.cpp | 39 ++++++++++++++++++++++++--------------- platform/x11/os_x11.h | 1 + 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index dc0dc063b9..3db1f6da25 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -46,7 +46,6 @@ struct ContextGL_X11_Private { ::GLXContext glx_context; }; - void ContextGL_X11::release_current() { glXMakeCurrent(x11_display, None, NULL); @@ -56,10 +55,12 @@ void ContextGL_X11::make_current() { glXMakeCurrent(x11_display, x11_window, p->glx_context); } + void ContextGL_X11::swap_buffers() { glXSwapBuffers(x11_display,x11_window); } + /* static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { @@ -154,6 +155,9 @@ Error ContextGL_X11::initialize() { */ //glXMakeCurrent(x11_display, None, NULL); + XFree( vi ); + XFree( fbc ); + return OK; } @@ -164,12 +168,12 @@ int ContextGL_X11::get_window_width() { return xwa.width; } + int ContextGL_X11::get_window_height() { XWindowAttributes xwa; XGetWindowAttributes(x11_display,x11_window,&xwa); return xwa.height; - } @@ -189,6 +193,8 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con ContextGL_X11::~ContextGL_X11() { + release_current(); + glXDestroyContext( x11_display, p->glx_context ); memdelete( p ); } diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 85928f2815..d538b4c7b6 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -153,6 +153,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XFree (xim_styles); } + XFree( imvalret ); } /* @@ -351,6 +352,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi for(int i=0;i