From: Good Guy Date: Thu, 31 Mar 2016 00:55:03 +0000 (-0600) Subject: fix pbuffer leak X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=b3ab80e6d0aff2c9971b7837d6bea590f78c3189;p=goodguy%2Fhistory.git fix pbuffer leak --- diff --git a/cinelerra-5.1/guicast/bcpbuffer.C b/cinelerra-5.1/guicast/bcpbuffer.C index 7249d834..f6e5dd99 100644 --- a/cinelerra-5.1/guicast/bcpbuffer.C +++ b/cinelerra-5.1/guicast/bcpbuffer.C @@ -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(w, h, pbuffer, glx_context); + BC_WindowBase::get_synchronous()->put_pbuffer(ww, hh, pbuffer, glx_context); } else printf("BC_PBuffer::create_pbuffer: failed\n"); diff --git a/cinelerra-5.1/guicast/bcsynchronous.C b/cinelerra-5.1/guicast/bcsynchronous.C index a8eccf23..35d4a1c1 100644 --- a/cinelerra-5.1/guicast/bcsynchronous.C +++ b/cinelerra-5.1/guicast/bcsynchronous.C @@ -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; } } diff --git a/cinelerra-5.1/guicast/bcsynchronous.h b/cinelerra-5.1/guicast/bcsynchronous.h index ba347b78..a9947a13 100644 --- a/cinelerra-5.1/guicast/bcsynchronous.h +++ b/cinelerra-5.1/guicast/bcsynchronous.h @@ -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);