fix pbuffer leak
authorGood Guy <good1.2guy@gmail.com>
Thu, 31 Mar 2016 00:55:03 +0000 (18:55 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 31 Mar 2016 00:55:03 +0000 (18:55 -0600)
cinelerra-5.1/guicast/bcpbuffer.C
cinelerra-5.1/guicast/bcsynchronous.C
cinelerra-5.1/guicast/bcsynchronous.h

index 7249d8344177603ccc2f947d8e73e88a3ae51465..f6e5dd9948ac95922c7efe55b891550060e9cd6e 100644 (file)
@@ -65,6 +65,12 @@ void BC_PBuffer::create_pbuffer(int w, int h)
 {
 #ifdef HAVE_GL
        int ww = (w + 3) & ~3, hh = (h + 3) & ~3;
+       BC_WindowBase *current_window = BC_WindowBase::get_synchronous()->current_window;
+       window_id = current_window->get_id();
+
+       pbuffer = BC_WindowBase::get_synchronous()->get_pbuffer(ww, hh, &glx_context);
+       if( pbuffer ) return;
+
        int pb_attrs[] = {
                GLX_PBUFFER_WIDTH, ww,
                GLX_PBUFFER_HEIGHT, hh,
@@ -73,7 +79,6 @@ void BC_PBuffer::create_pbuffer(int w, int h)
                None
        };
 
-       BC_WindowBase *current_window = BC_WindowBase::get_synchronous()->current_window;
        Display *dpy = current_window->get_display();
        GLXFBConfig *fb_cfgs = current_window->glx_pbuffer_fb_configs();
        int nfb_cfgs = current_window->n_fbcfgs_pbuffer;
@@ -92,9 +97,8 @@ void BC_PBuffer::create_pbuffer(int w, int h)
 // __LINE__, current_config, visinfo, BC_Resources::error, pbuffer);
 
        if( pbuffer ) {
-               window_id = current_window->get_id();
                glx_context = glXCreateContext(dpy, visinfo, current_window->glx_win_context, 1);
-               BC_WindowBase::get_synchronous()->put_pbuffer(wh, pbuffer, glx_context);
+               BC_WindowBase::get_synchronous()->put_pbuffer(ww, hh, pbuffer, glx_context);
        }
        else
                printf("BC_PBuffer::create_pbuffer: failed\n");
index a8eccf2356298c07765b52a5419f39a2f7ad8302..35d4a1c1b03abe6c60c14f95c4edb8b6e43ca488 100644 (file)
@@ -473,13 +473,12 @@ void BC_Synchronous::put_pbuffer(int w, int h,
        table_lock->lock("BC_Resources::release_textures");
        for(int i = 0; i < pbuffer_ids.total; i++) {
                PBufferID *ptr = pbuffer_ids.values[i];
-               if(ptr->w == w && ptr->h == h && ptr->glx_pbuffer == glx_pbuffer) {
+               if( ptr->w == w && ptr->h == h && ptr->glx_pbuffer == glx_pbuffer ) {
                        exists = 1;
                        break;
                }
        }
 
-
        if(!exists) {
                PBufferID *ptr = new PBufferID(current_window->get_id(),
                        glx_pbuffer, glx_context, w, h);
@@ -488,10 +487,7 @@ void BC_Synchronous::put_pbuffer(int w, int h,
        table_lock->unlock();
 }
 
-GLXPbuffer BC_Synchronous::get_pbuffer(int w,
-       int h,
-       int *window_id,
-       GLXContext *glx_context)
+GLXPbuffer BC_Synchronous::get_pbuffer(int w, int h, GLXContext *glx_context)
 {
        table_lock->lock("BC_Resources::release_textures");
        for(int i = 0; i < pbuffer_ids.total; i++) {
@@ -500,7 +496,6 @@ GLXPbuffer BC_Synchronous::get_pbuffer(int w,
                        ptr->window_id == current_window->get_id() ) {
                        GLXPbuffer result = ptr->glx_pbuffer;
                        *glx_context = ptr->glx_context;
-                       *window_id = ptr->window_id;
                        ptr->in_use = 1;
                        table_lock->unlock();
                        return result;
@@ -515,7 +510,7 @@ void BC_Synchronous::release_pbuffer(int window_id, GLXPbuffer pbuffer)
        table_lock->lock("BC_Resources::release_textures");
        for(int i = 0; i < pbuffer_ids.total; i++) {
                PBufferID *ptr = pbuffer_ids.values[i];
-               if(ptr->window_id == window_id) {
+               if( ptr->window_id == window_id ) {
                        ptr->in_use = 0;
                }
        }
index ba347b784189a0a8c05296690aeeb347c9e0a65f..a9947a13ce7512c1c6547ecd2c238113e143916a 100644 (file)
@@ -204,10 +204,7 @@ public:
                GLXContext glx_context);
 // Get the PBuffer by window_id and dimensions if it exists.
 // Must be called inside synchronous loop.
-       GLXPbuffer get_pbuffer(int w,
-               int h,
-               int *window_id,
-               GLXContext *glx_context);
+       GLXPbuffer get_pbuffer(int w, int h, GLXContext *glx_context);
 // Release a pbuffer for use by get_pbuffer.
        void release_pbuffer(int window_id, GLXPbuffer pbuffer);