From: Mikko Rasa Date: Fri, 28 Dec 2007 20:05:18 +0000 (+0000) Subject: Plug some memory leaks X-Git-Tag: 0.9~12 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f347e2259f66ca2d43deaf8da7bd718622b90f9e;p=libs%2Fgui.git Plug some memory leaks --- diff --git a/source/display.cpp b/source/display.cpp index b8e4fbe..ba5a640 100644 --- a/source/display.cpp +++ b/source/display.cpp @@ -73,6 +73,8 @@ Display::Display(const string &disp_name) modes.push_back(mode); } + XFree(infos); + XF86VidModeModeLine modeline; int dotclock; XF86VidModeGetModeLine(display, screen, &dotclock, &modeline); diff --git a/source/glcontext.cpp b/source/glcontext.cpp index 5995384..9377e88 100644 --- a/source/glcontext.cpp +++ b/source/glcontext.cpp @@ -65,9 +65,17 @@ GLContext::GLContext(Display &d, const GLOptions &opts): window=XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1024, 768, 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr); + XFree(vi); + glXMakeCurrent(dpy, window, context); } +GLContext::~GLContext() +{ + glXDestroyContext(display.get_display(), context); + XDestroyWindow(display.get_display(), window); +} + void GLContext::attach(Window &wnd) { XReparentWindow(display.get_display(), window, wnd.get_handle(), 0, 0); diff --git a/source/glcontext.h b/source/glcontext.h index 1156b53..f9e5f46 100644 --- a/source/glcontext.h +++ b/source/glcontext.h @@ -38,6 +38,8 @@ private: public: GLContext(Display &dpy, const GLOptions &opts); + ~GLContext(); + void attach(Window &wnd); void swap_buffers(); private: