]> git.tdb.fi Git - libs/gui.git/commitdiff
Create GLContext::priv later to avoid memory leaks
authorMikko Rasa <tdb@tdb.fi>
Sun, 12 Oct 2014 14:09:13 +0000 (17:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 12 Oct 2014 14:09:13 +0000 (17:09 +0300)
source/graphics/cgl/glcontext.cpp
source/graphics/glx/glcontext.cpp
source/graphics/wgl/glcontext.cpp

index 94b9b2f465652a36a215696ebfccfbf1fa6dbac0..7e06d2333aea4c631b0e956e0fbe6047d5380737 100644 (file)
@@ -19,8 +19,6 @@ struct GLContext::Private
 
 void GLContext::platform_init(const GLOptions &opts)
 {
-       priv = new Private;
-
        vector<unsigned> attribs;
        
        attribs.push_back(CPF_DEPTH_SIZE);
@@ -55,6 +53,7 @@ void GLContext::platform_init(const GLOptions &opts)
        if(!pixfmt)
                throw unsupported_gl_mode(opts);
 
+       priv = new Private;
        priv->context = create_gl_context(pixfmt);
        destroy_pixel_format(pixfmt);
 
index a73b9c554760af4f1c5d368b69605533c48be16f..b3d8ed0565d867e6f8ab06df0095232d81c73e04 100644 (file)
@@ -22,8 +22,6 @@ struct GLContext::Private
 
 void GLContext::platform_init(const GLOptions &opts)
 {
-       priv = new Private;
-
        vector<int> attribs;
        
        attribs.push_back(GLX_RGBA);
@@ -60,6 +58,8 @@ void GLContext::platform_init(const GLOptions &opts)
        XVisualInfo *vi = glXChooseVisual(dpy, DefaultScreen(dpy), &attribs.front());
        if(!vi)
                throw unsupported_gl_mode(opts);
+
+       priv = new Private;
        priv->context = glXCreateContext(dpy, vi, 0, true);
 
        XSetWindowAttributes attr;
index 964dea2b7fba92a66815b7d84e89254c0c840880..05f9533de839322057b6b896eb8bc0cfabd3636d 100644 (file)
@@ -16,8 +16,6 @@ struct GLContext::Private
 
 void GLContext::platform_init(const GLOptions &opts)
 {
-       priv = new Private;
-
        HDC dc = GetDC(window.get_private().window);
 
        PIXELFORMATDESCRIPTOR pfd;
@@ -40,6 +38,7 @@ void GLContext::platform_init(const GLOptions &opts)
                throw unsupported_gl_mode(opts);
        SetPixelFormat(dc, pf_index, &pfd);
 
+       priv = new Private;
        priv->context = wglCreateContext(dc);
        wglMakeCurrent(dc, priv->context);