X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmainundo.C;h=0c149cd40acc445d8626a060b7f7cae831ce0e00;hp=bd048c10de5fa84fcc816206386b8079b753192c;hb=HEAD;hpb=ae3fc4be2e74120251506615bb29b853c6e10ff6 diff --git a/cinelerra-5.1/cinelerra/mainundo.C b/cinelerra-5.1/cinelerra/mainundo.C index bd048c10..0c149cd4 100644 --- a/cinelerra-5.1/cinelerra/mainundo.C +++ b/cinelerra-5.1/cinelerra/mainundo.C @@ -22,6 +22,7 @@ #include "asset.h" #include "assets.h" #include "bctimer.h" +#include "clipedls.h" #include "edl.h" #include "filexml.h" #include "mainindexes.h" @@ -30,7 +31,6 @@ #include "mainundo.h" #include "mwindow.h" #include "mwindowgui.h" -#include "nestededls.h" #include #include "undostack.h" @@ -55,10 +55,7 @@ void MainUndo::update_undo_entry(const char *description, { FileXML file; - mwindow->edl->save_xml(&file, - "", - 0, - 0); + mwindow->edl->save_xml(&file, ""); file.terminate_string(); if(changes_made) mwindow->session->changes_made = 1; @@ -190,25 +187,27 @@ int MainUndo::redo_load_flags() int MainUndo::undo() { mwindow->undo_commercial(); - - UndoStackItem *current = next_undo(); -// Now have an even number + UndoStackItem *current = undo_stack->current; + if( current ) { + undo_stack->current = next_undo(); + if( undo_stack->number_of(current) % 2 ) + current = PREVIOUS; // Now have an even number + } if( current ) { - undo_stack->current = current; // Set the redo text to the current description if( mwindow->gui ) { UndoStackItem *next = NEXT; mwindow->gui->mainmenu->redo-> update_caption(next ? next->get_description() : ""); } - FileXML file; char *current_data = current->get_data(); if( current_data ) { + FileXML file; file.read_from_string(current_data); + delete [] current_data; load_from_undo(&file, current->get_flags()); //printf("MainUndo::undo %d %s\n", __LINE__, current->get_filename()); mwindow->set_filename(current->get_filename()); - delete [] current_data; if( mwindow->gui ) { // Now update the menu with the after entry @@ -232,21 +231,18 @@ int MainUndo::redo() undo_stack->current = current; char *current_data = current->get_data(); if( current_data ) { - FileXML file; mwindow->set_filename(current->get_filename()); + FileXML file; file.read_from_string(current_data); load_from_undo(&file, current->get_flags()); delete [] current_data; - - if( mwindow->gui ) { // Update menu - mwindow->gui->mainmenu->undo-> - update_caption(current->get_description()); + mwindow->gui->mainmenu->undo-> + update_caption(current->get_description()); // Get next after entry - if( (current=NEXT) ) current = NEXT; - mwindow->gui->mainmenu->redo-> - update_caption(current ? current->get_description() : ""); - } + if( (current=NEXT) ) current = NEXT; + mwindow->gui->mainmenu->redo-> + update_caption(current ? current->get_description() : ""); } } reset_creators(); @@ -259,35 +255,40 @@ int MainUndo::redo() // Here the master EDL loads int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) { - if( load_flags & LOAD_SESSION ) + delete mwindow->gui->keyvalue_popup; + mwindow->gui->keyvalue_popup = 0; + + if( load_flags & LOAD_SESSION ) { + mwindow->gui->unlock_window(); mwindow->close_mixers(); + mwindow->gui->lock_window("MainUndo::load_from_undo"); + } + if( (load_flags & LOAD_ALL) == LOAD_ALL ) { + mwindow->edl->remove_user(); + mwindow->init_edl(); + } mwindow->edl->load_xml(file, load_flags); - for(Asset *asset = mwindow->edl->assets->first; - asset; - asset = asset->next) - { + for( Asset *asset=mwindow->edl->assets->first; asset; asset=asset->next ) { mwindow->mainindexes->add_next_asset(0, asset); } - - for(int i = 0; i < mwindow->edl->nested_edls->size(); i++) - { - EDL *nested_edl = mwindow->edl->nested_edls->get(i); + for( int i=0; iedl->nested_edls.size(); ++i ) { + EDL *nested_edl = mwindow->edl->nested_edls[i]; mwindow->mainindexes->add_next_asset(0, nested_edl); } mwindow->mainindexes->start_build(); mwindow->update_plugin_guis(1); - if( load_flags & LOAD_SESSION ) + if( load_flags & LOAD_SESSION ) { + mwindow->gui->unlock_window(); mwindow->open_mixers(); + mwindow->gui->lock_window("MainUndo::load_from_undo"); + } return 0; } void MainUndo::reset_creators() { - for(UndoStackItem *current = undo_stack->first; - current; - current = NEXT) - { + for( UndoStackItem *current=undo_stack->first; current; current=NEXT ) { current->set_creator(0); } } @@ -298,3 +299,30 @@ void MainUndo::dump(FILE *fp) undo_stack->dump(fp); } +void MainUndo::save(FILE *fp) +{ + undo_stack->save(fp); +} + +void MainUndo::load(FILE *fp) +{ + undo_stack->load(fp); + UndoStackItem *current = undo_stack->current; + char *current_data = current ? current->get_data() : 0; + if( !current_data ) return; + mwindow->gui->lock_window("MainUndo::load"); + UndoStackItem *next = current->next; + mwindow->gui->mainmenu->redo-> + update_caption(next ? next->get_description() : ""); + mwindow->set_filename(current->get_filename()); + FileXML file; + file.read_from_string(current_data); + load_from_undo(&file, LOAD_ALL); + delete [] current_data; + UndoStackItem *prev = current->previous; + mwindow->gui->mainmenu->undo-> + update_caption(prev ? prev->get_description() : ""); + mwindow->update_project(LOADMODE_REPLACE); + mwindow->gui->unlock_window(); +} +