From: Good Guy Date: Sun, 17 Dec 2017 21:38:03 +0000 (-0700) Subject: memory leaks and tweaks, sams histeq icon X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=ce9d2233f4653ae54ee7bdfa4a7313326a9d8240;p=goodguy%2Fhistory.git memory leaks and tweaks, sams histeq icon --- diff --git a/cinelerra-5.1/cinelerra/assetremove.C b/cinelerra-5.1/cinelerra/assetremove.C index ec2c0f8c..49e82414 100644 --- a/cinelerra-5.1/cinelerra/assetremove.C +++ b/cinelerra-5.1/cinelerra/assetremove.C @@ -46,7 +46,10 @@ AssetRemoveWindow::AssetRemoveWindow(MWindow *mwindow) AssetRemoveWindow::~AssetRemoveWindow() { - delete data; + if( data ) { + data->remove_all_objects(); + delete data; + } } void AssetRemoveWindow::create_objects() diff --git a/cinelerra-5.1/cinelerra/mainerror.C b/cinelerra-5.1/cinelerra/mainerror.C index ceeffc4a..4dc01aec 100644 --- a/cinelerra-5.1/cinelerra/mainerror.C +++ b/cinelerra-5.1/cinelerra/mainerror.C @@ -121,6 +121,7 @@ MainError::MainError(MWindow *mwindow) MainError::~MainError() { close_window(); + errors.remove_all_objects(); delete errors_lock; } diff --git a/cinelerra-5.1/cinelerra/mainindexes.C b/cinelerra-5.1/cinelerra/mainindexes.C index d871a50b..05812bb7 100644 --- a/cinelerra-5.1/cinelerra/mainindexes.C +++ b/cinelerra-5.1/cinelerra/mainindexes.C @@ -91,13 +91,6 @@ SET_TRACE next_lock->unlock(); } -void MainIndexes::delete_current_sources() -{ - for(int i = 0; i < current_indexables.size(); i++) - current_indexables.get(i)->Garbage::remove_user(); - current_indexables.remove_all(); -} - void MainIndexes::start_loop() { interrupt_flag = 0; @@ -140,8 +133,6 @@ void MainIndexes::interrupt_build() void MainIndexes::load_next_sources() { - delete_current_sources(); - // Transfer from new list next_lock->lock("MainIndexes::load_next_sources"); for(int i = 0; i < next_indexables.size(); i++) @@ -166,13 +157,14 @@ void MainIndexes::run() // test index of each indexable MainProgressBar *progress = 0; - int total_sources = current_indexables.size(); - for( int i = 0; i < total_sources && !interrupt_flag; ++i ) { + next_lock->lock("MainIndexes::run"); + for( int i=0; iindex_state; // if status is known, no probe if( index_state->index_status != INDEX_NOTTESTED ) continue; + next_lock->unlock(); IndexFile indexfile(mwindow, indexable); int ret = indexfile.open_index(); @@ -195,8 +187,14 @@ void MainIndexes::run() indexfile.create_index(progress); if( progress->is_cancelled() ) interrupt_flag = 1; + next_lock->lock("MainIndexes::run"); } + for( int i=0; iremove_user(); + current_indexables.remove_all(); + next_lock->unlock(); + if(progress) { // progress box is only created when an index is built if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 3"); progress->stop_progress(); diff --git a/cinelerra-5.1/cinelerra/mainindexes.h b/cinelerra-5.1/cinelerra/mainindexes.h index c769d7e0..810dcd87 100644 --- a/cinelerra-5.1/cinelerra/mainindexes.h +++ b/cinelerra-5.1/cinelerra/mainindexes.h @@ -47,7 +47,6 @@ public: void run(); void interrupt_build(); void load_next_sources(); - void delete_current_sources(); ArrayList current_indexables; ArrayList next_indexables; diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 31790067..9bab2c61 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -1695,8 +1695,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Define new_edls and new_assets to load int result = 0, ftype = -1; - for(int i = 0; i < filenames->size(); i++) - { + + for( int i=0; isize(); ++i ) { // Get type of file File *new_file = new File; Asset *new_asset = new Asset(filenames->get(i)); @@ -1715,234 +1715,210 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); result = 1; - switch(ftype) - { + switch( ftype ) { // Convert media file to EDL - case FILE_OK: + case FILE_OK: // Warn about odd image dimensions - if(new_asset->video_data && - ((new_asset->width % 2) || - (new_asset->height % 2))) - { - char string[BCTEXTLEN]; - sprintf(string, _("%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly."), - new_asset->path, - new_asset->width, - new_asset->height); - MainError::show_error(string); - } - - if(new_asset->program >= 0 && - edl->session->program_no != new_asset->program) - { - char string[BCTEXTLEN]; - sprintf(string, _("%s's index was built for program number %d\n" - "Playback preference is %d.\n Using program %d."), - new_asset->path, new_asset->program, - edl->session->program_no, new_asset->program); - MainError::show_error(string); - } + if( new_asset->video_data && + ((new_asset->width % 2) || (new_asset->height % 2)) ) { + char string[BCTEXTLEN]; + sprintf(string, _("%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly."), + new_asset->path, new_asset->width, new_asset->height); + MainError::show_error(string); + } + if( new_asset->program >= 0 && + edl->session->program_no != new_asset->program ) { + char string[BCTEXTLEN]; + sprintf(string, _("%s's index was built for program number %d\n" + "Playback preference is %d.\n Using program %d."), + new_asset->path, new_asset->program, + edl->session->program_no, new_asset->program); + MainError::show_error(string); + } - if(load_mode != LOADMODE_RESOURCESONLY) - { - RecordLabels *labels = edl->session->label_cells ? - new RecordLabels(new_file) : 0; - asset_to_edl(new_edl, new_asset, labels); - new_edls.append(new_edl); - new_asset->Garbage::remove_user(); - delete labels; - new_asset = 0; - } - else - { - new_assets.append(new_asset); - new_asset = 0; - } + if( load_mode != LOADMODE_RESOURCESONLY ) { + RecordLabels *labels = edl->session->label_cells ? + new RecordLabels(new_file) : 0; + asset_to_edl(new_edl, new_asset, labels); + new_edls.append(new_edl); + new_edl->add_user(); + delete labels; + } + else { + new_assets.append(new_asset); + new_asset->add_user(); + } // Set filename to nothing for assets since save EDL would overwrite them. - if(load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE) - { - set_filename(""); + if( load_mode == LOADMODE_REPLACE || + load_mode == LOADMODE_REPLACE_CONCATENATE ) { + set_filename(""); // Reset timeline position - for(int i = 0; i < TOTAL_PANES; i++) - { - new_edl->local_session->view_start[i] = 0; - new_edl->local_session->track_start[i] = 0; - } + for( int i=0; ilocal_session->view_start[i] = 0; + new_edl->local_session->track_start[i] = 0; } + } - result = 0; - break; + result = 0; + break; // File not found - case FILE_NOT_FOUND: - sprintf(string, _("Failed to open %s"), new_asset->path); - gui->show_message(string, theme->message_error); - gui->update_default_message(); - break; + case FILE_NOT_FOUND: + sprintf(string, _("Failed to open %s"), new_asset->path); + gui->show_message(string, theme->message_error); + gui->update_default_message(); + break; // Unknown format - case FILE_UNRECOGNIZED_CODEC: - { + case FILE_UNRECOGNIZED_CODEC: { // Test index file - { IndexFile indexfile(this, new_asset); - if( !(result = indexfile.open_index()) ) - indexfile.close_index(); - } + { IndexFile indexfile(this, new_asset); + if( !(result = indexfile.open_index()) ) + indexfile.close_index(); } // Test existing EDLs - for(int j = 0; result && j <= new_edls.total; j++) { - Asset *old_asset = j < new_edls.total ? - new_edls[j]->assets->get_asset(new_asset->path) : - edl->assets->get_asset(new_asset->path); - if( old_asset ) { - new_asset->copy_from(old_asset,1); - result = 0; - } + for( int j=0; result && jassets->get_asset(new_asset->path); + if( old_asset ) { + new_asset->copy_from(old_asset,1); + result = 0; } + } + if( result ) { + Asset *old_asset = edl->assets->get_asset(new_asset->path); + if( old_asset ) { + new_asset->copy_from(old_asset,1); + result = 0; + } + } // Prompt user - if(result) - { - char string[BCTEXTLEN]; - FileSystem fs; - fs.extract_name(string, new_asset->path); - - strcat(string, _("'s format couldn't be determined.")); - new_asset->audio_data = 1; - new_asset->format = FILE_PCM; - new_asset->channels = defaults->get("AUDIO_CHANNELS", 2); - new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100); - new_asset->bits = defaults->get("AUDIO_BITS", 16); - new_asset->byte_order = defaults->get("BYTE_ORDER", 1); - new_asset->signed_ = defaults->get("SIGNED_", 1); - new_asset->header = defaults->get("HEADER", 0); - - FileFormat fwindow(this); - fwindow.create_objects(new_asset, string); - result = fwindow.run_window(); - - - defaults->update("AUDIO_CHANNELS", new_asset->channels); - defaults->update("SAMPLE_RATE", new_asset->sample_rate); - defaults->update("AUDIO_BITS", new_asset->bits); - defaults->update("BYTE_ORDER", new_asset->byte_order); - defaults->update("SIGNED_", new_asset->signed_); - defaults->update("HEADER", new_asset->header); - save_defaults(); - } + if( result ) { + char string[BCTEXTLEN]; + FileSystem fs; + fs.extract_name(string, new_asset->path); + + strcat(string, _("'s format couldn't be determined.")); + new_asset->audio_data = 1; + new_asset->format = FILE_PCM; + new_asset->channels = defaults->get("AUDIO_CHANNELS", 2); + new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100); + new_asset->bits = defaults->get("AUDIO_BITS", 16); + new_asset->byte_order = defaults->get("BYTE_ORDER", 1); + new_asset->signed_ = defaults->get("SIGNED_", 1); + new_asset->header = defaults->get("HEADER", 0); + + FileFormat fwindow(this); + fwindow.create_objects(new_asset, string); + result = fwindow.run_window(); + + defaults->update("AUDIO_CHANNELS", new_asset->channels); + defaults->update("SAMPLE_RATE", new_asset->sample_rate); + defaults->update("AUDIO_BITS", new_asset->bits); + defaults->update("BYTE_ORDER", new_asset->byte_order); + defaults->update("SIGNED_", new_asset->signed_); + defaults->update("HEADER", new_asset->header); + save_defaults(); + } // Append to list - if(!result) - { + if( !result ) { // Recalculate length - delete new_file; - new_file = new File; - result = new_file->open_file(preferences, new_asset, 1, 0); + delete new_file; + new_file = new File; + result = new_file->open_file(preferences, new_asset, 1, 0); - if(load_mode != LOADMODE_RESOURCESONLY) - { - RecordLabels *labels = edl->session->label_cells ? - new RecordLabels(new_file) : 0; - asset_to_edl(new_edl, new_asset, labels); - new_edls.append(new_edl); - new_asset->Garbage::remove_user(); - delete labels; - new_asset = 0; - } - else - { - new_assets.append(new_asset); - new_asset = 0; - } + if( load_mode != LOADMODE_RESOURCESONLY ) { + RecordLabels *labels = edl->session->label_cells ? + new RecordLabels(new_file) : 0; + asset_to_edl(new_edl, new_asset, labels); + new_edls.append(new_edl); + new_edl->add_user(); + delete labels; } - else - { - result = 1; + else { + new_assets.append(new_asset); + new_asset->add_user(); } - break; } + else { + result = 1; + } + break; } - case FILE_IS_XML: - { - FileXML xml_file; + case FILE_IS_XML: { + FileXML xml_file; if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - xml_file.read_from_file(filenames->get(i)); + xml_file.read_from_file(filenames->get(i)); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - const char *cin_version = 0; - while( !xml_file.read_tag() ) { - if( xml_file.tag.title_is("EDL") ) { - cin_version = xml_file.tag.get_property("VERSION"); - break; - } - } - xml_file.rewind(); - if( !cin_version ) { - eprintf(_("XML file %s\n not from cinelerra."),filenames->get(i)); - char string[BCTEXTLEN]; - sprintf(string,_("Unknown %s"), filenames->get(i)); - gui->show_message(string); - result = 1; + const char *cin_version = 0; + while( !xml_file.read_tag() ) { + if( xml_file.tag.title_is("EDL") ) { + cin_version = xml_file.tag.get_property("VERSION"); break; } - if( strcmp(cin_version, CINELERRA_VERSION) ) { - char string[BCTEXTLEN]; - snprintf(string, sizeof(string), - _("Warning: XML from cinelerra version %s\n" - "Session data may be incompatible."), cin_version); - show_warning(&preferences->warn_version, string); - } - if(load_mode == LOADMODE_NESTED) - { + } + xml_file.rewind(); + if( !cin_version ) { + eprintf(_("XML file %s\n not from cinelerra."),filenames->get(i)); + char string[BCTEXTLEN]; + sprintf(string,_("Unknown %s"), filenames->get(i)); + gui->show_message(string); + result = 1; + break; + } + if( strcmp(cin_version, CINELERRA_VERSION) ) { + char string[BCTEXTLEN]; + snprintf(string, sizeof(string), + _("Warning: XML from cinelerra version %s\n" + "Session data may be incompatible."), cin_version); + show_warning(&preferences->warn_version, string); + } + if( load_mode == LOADMODE_NESTED ) { // Load temporary EDL for nesting. - EDL *nested_edl = new EDL; - nested_edl->create_objects(); - nested_edl->set_path(filenames->get(i)); - nested_edl->load_xml(&xml_file, LOAD_ALL); + EDL *nested_edl = new EDL; + nested_edl->create_objects(); + nested_edl->set_path(filenames->get(i)); + nested_edl->load_xml(&xml_file, LOAD_ALL); //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path); - edl_to_nested(new_edl, nested_edl); - nested_edl->Garbage::remove_user(); - } - else - { + edl_to_nested(new_edl, nested_edl); + nested_edl->Garbage::remove_user(); + } + else { // Load EDL for pasting - new_edl->load_xml(&xml_file, LOAD_ALL); + new_edl->load_xml(&xml_file, LOAD_ALL); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - test_plugins(new_edl, filenames->get(i)); + test_plugins(new_edl, filenames->get(i)); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - if(load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE) - { - strcpy(session->filename, filenames->get(i)); - strcpy(new_edl->local_session->clip_title, - filenames->get(i)); - if(update_filename) - set_filename(new_edl->local_session->clip_title); - } - else - if( load_mode == LOADMODE_RESOURCESONLY ) { - strcpy(new_edl->local_session->clip_title, - filenames->get(i)); - struct stat st; - time_t t = !stat(filenames->get(i),&st) ? - st.st_mtime : time(&t); - ctime_r(&t, new_edl->local_session->clip_notes); - } + if( load_mode == LOADMODE_REPLACE || + load_mode == LOADMODE_REPLACE_CONCATENATE ) { + strcpy(session->filename, filenames->get(i)); + strcpy(new_edl->local_session->clip_title, + filenames->get(i)); + if(update_filename) + set_filename(new_edl->local_session->clip_title); + } + else if( load_mode == LOADMODE_RESOURCESONLY ) { + strcpy(new_edl->local_session->clip_title, + filenames->get(i)); + struct stat st; + time_t t = !stat(filenames->get(i),&st) ? + st.st_mtime : time(&t); + ctime_r(&t, new_edl->local_session->clip_notes); } - - new_edls.append(new_edl); - result = 0; - break; } + + new_edls.append(new_edl); + new_edl->add_user(); + result = 0; + break; } } -// edls are in new_edls - if( result && new_edl ) new_edl->Garbage::remove_user(); -// assets are copied - if( new_asset ) new_asset->Garbage::remove_user(); + new_edl->Garbage::remove_user(); + new_asset->Garbage::remove_user(); // Store for testing index new_files.append(new_file); diff --git a/cinelerra-5.1/cinelerra/packagerenderer.C b/cinelerra-5.1/cinelerra/packagerenderer.C index e0508099..4318bec7 100644 --- a/cinelerra-5.1/cinelerra/packagerenderer.C +++ b/cinelerra-5.1/cinelerra/packagerenderer.C @@ -105,6 +105,7 @@ PackageRenderer::~PackageRenderer() delete video_cache; delete vconfig; delete aconfig; + delete timer; } // PackageRenderer::initialize happens only once for every node when doing rendering session diff --git a/cinelerra-5.1/cinelerra/removefile.h b/cinelerra-5.1/cinelerra/removefile.h index b2f35fa5..371c0710 100644 --- a/cinelerra-5.1/cinelerra/removefile.h +++ b/cinelerra-5.1/cinelerra/removefile.h @@ -40,12 +40,13 @@ public: void wait() { Thread::join(); delete this; } static void removeFile(const char *path) { RemoveFile *rf = new RemoveFile(path,1); - rf->run(); + rf->start(); } static void removeFileWait(const char *path) { if( ::access(path, F_OK) ) return; RemoveFile *rf = new RemoveFile(path,0); - rf->run(); rf->wait(); + rf->start(); rf->wait(); + delete rf; } }; diff --git a/cinelerra-5.1/cinelerra/render.C b/cinelerra-5.1/cinelerra/render.C index 5ce03541..f50ae895 100644 --- a/cinelerra-5.1/cinelerra/render.C +++ b/cinelerra-5.1/cinelerra/render.C @@ -255,9 +255,7 @@ Render::~Render() delete package_lock; delete counter_lock; delete completion; -// May be owned by someone else. This is owned by mwindow, so we don't care -// about deletion. -// delete preferences; + delete preferences; delete progress_timer; if( asset ) asset->Garbage::remove_user(); delete thread; @@ -314,13 +312,11 @@ void Render::start_batches(ArrayList *jobs, mode = Render::BATCH; batch_cancelled = 0; this->jobs = jobs; - this->preferences = preferences; + this->preferences = new Preferences; + this->preferences->copy_from(preferences); completion->reset(); -PRINT_TRACE thread->run(); -PRINT_TRACE - this->preferences = 0; } @@ -715,15 +711,12 @@ void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl, render->progress = 0; render->result = 0; - if(mwindow) - { - if(!render->preferences) + if( mwindow ) { + if( !render->preferences ) render->preferences = new Preferences; - render->preferences->copy_from(mwindow->preferences); } - // Create rendering command TransportCommand *command = new TransportCommand; command->command = NORMAL_FWD; @@ -1135,6 +1128,9 @@ RenderWindow::RenderWindow(MWindow *mwindow, this->mwindow = mwindow; this->render = render; this->asset = asset; + render_format = 0; + loadmode = 0; + renderprofile = 0; rangeproject = 0; rangeselection = 0; rangeinout = 0; @@ -1143,15 +1139,11 @@ RenderWindow::RenderWindow(MWindow *mwindow, RenderWindow::~RenderWindow() { -SET_TRACE lock_window("RenderWindow::~RenderWindow"); -SET_TRACE delete render_format; -SET_TRACE delete loadmode; -SET_TRACE + delete renderprofile; unlock_window(); -SET_TRACE } diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C index 26ccf9a4..b27f43a2 100644 --- a/cinelerra-5.1/guicast/thread.C +++ b/cinelerra-5.1/guicast/thread.C @@ -65,8 +65,8 @@ void* Thread::entrypoint(void *parameters) thread->run(); thread->finished = true; if( !thread->synchronous ) { - if( !thread->cancelled ) TheList::dbg_del(thread->tid); if( thread->autodelete ) delete thread; + else if( !thread->cancelled ) TheList::dbg_del(thread->tid); else thread->tid = ((pthread_t)-1); } return NULL; @@ -106,9 +106,13 @@ void Thread::start() perror("Thread::start pthread_attr_setinheritsched"); } +// autodelete may delete this immediately after create + int autodelete = this->autodelete; + pthread_create(&tid, &attr, Thread::entrypoint, this); - TheList::dbg_add(tid, owner, typeid(*this).name()); + if( !autodelete ) + TheList::dbg_add(tid, owner, typeid(*this).name()); } int Thread::cancel() diff --git a/cinelerra-5.1/picon/cinfinity/histeq.png b/cinelerra-5.1/picon/cinfinity/histeq.png index 658d2f38..a2a4bbee 100644 Binary files a/cinelerra-5.1/picon/cinfinity/histeq.png and b/cinelerra-5.1/picon/cinfinity/histeq.png differ