From 8bd72f90925843be9ab9182c89761ee0640e7873 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Fri, 31 Aug 2018 14:18:48 -0600 Subject: [PATCH] modify folder segv fix, opengl pbfr resource conflict fix --- cinelerra-5.1/cinelerra/binfolder.C | 6 ++++-- cinelerra-5.1/cinelerra/binfolder.h | 2 ++ cinelerra-5.1/cinelerra/edl.C | 2 +- cinelerra-5.1/cinelerra/mwindow.C | 2 +- cinelerra-5.1/cinelerra/playback3d.C | 31 ++++++++++++--------------- cinelerra-5.1/guicast/bcsynchronous.C | 3 ++- cinelerra-5.1/guicast/bctexture.C | 8 ++++--- cinelerra-5.1/guicast/vframe3d.C | 4 ++-- 8 files changed, 31 insertions(+), 27 deletions(-) diff --git a/cinelerra-5.1/cinelerra/binfolder.C b/cinelerra-5.1/cinelerra/binfolder.C index 593bfdab..84f97699 100644 --- a/cinelerra-5.1/cinelerra/binfolder.C +++ b/cinelerra-5.1/cinelerra/binfolder.C @@ -1826,6 +1826,7 @@ ModifyFolderThread::ModifyFolderThread(AWindowGUI *agui) { this->agui = agui; original = 0; + modify_edl = 0; folder = 0; } @@ -1839,7 +1840,8 @@ void ModifyFolderThread::start(BinFolder *folder, int x, int y, int w, int h) { close_window(); this->original = folder; - agui->mwindow->edl->add_user(); + this->modify_edl = agui->mwindow->edl; + this->modify_edl->add_user(); this->folder = new BinFolder(*folder); this->wx = x; this->wy = y; this->ww = w; this->wh = h; @@ -1872,7 +1874,7 @@ void ModifyFolderThread::handle_done_event(int result) } delete folder; folder = 0; original = 0; - agui->mwindow->edl->remove_user(); + modify_edl->remove_user(); } void ModifyFolderThread::handle_close_event(int result) diff --git a/cinelerra-5.1/cinelerra/binfolder.h b/cinelerra-5.1/cinelerra/binfolder.h index 5bf0a55f..97b13355 100644 --- a/cinelerra-5.1/cinelerra/binfolder.h +++ b/cinelerra-5.1/cinelerra/binfolder.h @@ -26,6 +26,7 @@ #include "awindowgui.inc" #include "binfolder.inc" #include "datatype.h" +#include "edl.inc" #include "filesystem.h" #include "guicast.h" #include "indexable.h" @@ -599,6 +600,7 @@ public: AWindowGUI *agui; BinFolder *original, *folder; ModifyFolderGUI *window; + EDL *modify_edl; }; diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 2f0d6e20..154f929a 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -410,7 +410,7 @@ void EDL::copy_session(EDL *edl, int session_only) session->copy(edl->session); } - if( !session_only ) { + if( session_only <= 0 ) { local_session->copy_from(edl->local_session); } } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index f4a850b9..e57f6657 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -1839,7 +1839,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); char string[BCTEXTLEN]; new_edl->create_objects(); - new_edl->copy_session(edl); + new_edl->copy_session(edl, -1); new_file->set_program(edl->session->program_no); sprintf(string, _("Loading %s"), new_asset->path); diff --git a/cinelerra-5.1/cinelerra/playback3d.C b/cinelerra-5.1/cinelerra/playback3d.C index 6d6dee35..ba21998c 100644 --- a/cinelerra-5.1/cinelerra/playback3d.C +++ b/cinelerra-5.1/cinelerra/playback3d.C @@ -960,19 +960,6 @@ void Playback3D::overlay_sync(Playback3DCommand *command) glColor4f(1, 1, 1, 1); glDisable(GL_BLEND); - if(command->frame) { -// Render to PBuffer - command->frame->enable_opengl(); - command->frame->set_opengl_state(VFrame::SCREEN); - canvas_w = command->frame->get_w(); - canvas_h = command->frame->get_h(); - } - else { -// Render to canvas - canvas_w = window->get_w(); - canvas_h = window->get_h(); - } - //printf("Playback3D::overlay_sync 1 %d\n", command->input->get_opengl_state()); switch( command->input->get_opengl_state() ) { @@ -987,16 +974,26 @@ void Playback3D::overlay_sync(Playback3DCommand *command) case VFrame::SCREEN: command->input->enable_opengl(); command->input->screen_to_texture(); - if(command->frame) - command->frame->enable_opengl(); - else - window->enable_opengl(); break; default: printf("Playback3D::overlay_sync unknown state\n"); break; } + if(command->frame) { +// Render to PBuffer + command->frame->enable_opengl(); + command->frame->set_opengl_state(VFrame::SCREEN); + canvas_w = command->frame->get_w(); + canvas_h = command->frame->get_h(); + } + else { +// Render to canvas + window->enable_opengl(); + canvas_w = window->get_w(); + canvas_h = window->get_h(); + } + const char *shader_stack[16]; memset(shader_stack,0, sizeof(shader_stack)); diff --git a/cinelerra-5.1/guicast/bcsynchronous.C b/cinelerra-5.1/guicast/bcsynchronous.C index 3c0e601d..0bc4f104 100644 --- a/cinelerra-5.1/guicast/bcsynchronous.C +++ b/cinelerra-5.1/guicast/bcsynchronous.C @@ -512,7 +512,8 @@ 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->glx_pbuffer == pbuffer ) { ptr->in_use = 0; } } diff --git a/cinelerra-5.1/guicast/bctexture.C b/cinelerra-5.1/guicast/bctexture.C index b527b4e1..59e21810 100644 --- a/cinelerra-5.1/guicast/bctexture.C +++ b/cinelerra-5.1/guicast/bctexture.C @@ -33,7 +33,6 @@ BC_Texture::BC_Texture(int w, int h, int colormodel) this->h = h; this->colormodel = colormodel; texture_id = -1; - texture_id = -1; texture_w = 0; texture_h = 0; texture_components = 0; @@ -247,11 +246,14 @@ void BC_Texture::write_tex(const char *fn) #ifdef HAVE_GL int prev_id = -1; glGetIntegerv(GL_ACTIVE_TEXTURE, &prev_id); - glActiveTexture(this->texture_id); + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_2D, texture_id); + glEnable(GL_TEXTURE_2D); int w = get_texture_w(), h = get_texture_h(); - uint8_t img[w*h*3]; + uint8_t *img = new uint8_t[w*h*3]; glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, img); write_ppm(img, w, h, "%s", fn); + delete img; glActiveTexture(prev_id); #endif } diff --git a/cinelerra-5.1/guicast/vframe3d.C b/cinelerra-5.1/guicast/vframe3d.C index 65eb1f3e..65d9d5ce 100644 --- a/cinelerra-5.1/guicast/vframe3d.C +++ b/cinelerra-5.1/guicast/vframe3d.C @@ -151,8 +151,8 @@ void VFrame::to_texture() void VFrame::create_pbuffer() { - if(pbuffer && - pbuffer->window_id != BC_WindowBase::get_synchronous()->current_window->get_id()) + if( pbuffer && (pbuffer->w != get_w() || pbuffer->h != get_h() || + pbuffer->window_id != BC_WindowBase::get_synchronous()->current_window->get_id() ) ) { delete pbuffer; pbuffer = 0; -- 2.26.2