diff options
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/undofile.c | 148 |
2 files changed, 1 insertions, 149 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a9a5b16b462..f75af94ea4f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2720,7 +2720,7 @@ void lib_link_screen_restore(Main *newmain, char mode, Scene *curscene) } else if(sl->spacetype==SPACE_IMASEL) { - check_imasel_copy((SpaceImaSel *)sl); + ; } else if(sl->spacetype==SPACE_ACTION) { SpaceAction *saction= (SpaceAction *)sl; diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index 25ed891f0a4..af278c89133 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -148,151 +148,3 @@ void add_memfilechunk(MemFile *compare, MemFile *current, char *buf, unsigned in } } -/* ***************** GLOBAL UNDO *************** */ - -#define UNDO_DISK 0 - -#define MAXUNDONAME 64 -typedef struct UndoElem { - struct UndoElem *next, *prev; - char str[FILE_MAXDIR+FILE_MAXFILE]; - char name[MAXUNDONAME]; - MemFile memfile; -} UndoElem; - -#define MAXUNDO 32 -static ListBase undobase={NULL, NULL}; -static UndoElem *curundo= NULL; - - -static int read_undosave(UndoElem *uel) -{ - char scestr[FILE_MAXDIR+FILE_MAXFILE]; - int success=0, fileflags; - - strcpy(scestr, G.sce); /* temporal store */ - fileflags= G.fileflags; - G.fileflags |= G_FILE_NO_UI; - - if(UNDO_DISK) - success= BKE_read_file(uel->str, NULL); - else - success= BKE_read_file_from_memfile(&uel->memfile); - - /* restore */ - strcpy(G.sce, scestr); - G.fileflags= fileflags; - - return success; -} - -/* name can be a dynamic string */ -void BIF_write_undo(char *name) -{ - int nr, success; - UndoElem *uel; - - if( (U.uiflag & USER_GLOBALUNDO)==0) return; - - /* remove all undos after (also when curundo==NULL) */ - while(undobase.last != curundo) { - uel= undobase.last; - BLI_remlink(&undobase, uel); - BLO_free_memfile(&uel->memfile); - MEM_freeN(uel); - } - - /* make new */ - curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file"); - strncpy(uel->name, name, MAXUNDONAME-1); - BLI_addtail(&undobase, uel); - - /* and limit amount to the maximum */ - nr= 0; - uel= undobase.last; - while(uel) { - nr++; - if(nr==MAXUNDO) break; - uel= uel->prev; - } - if(uel) { - while(undobase.first!=uel) { - UndoElem *first= undobase.first; - BLI_remlink(&undobase, first); - /* the merge is because of compression */ - BLO_merge_memfile(&first->memfile, &first->next->memfile); - MEM_freeN(first); - } - } - - - /* disk save version */ - if(UNDO_DISK) { - static int counter= 0; - char *err, tstr[FILE_MAXDIR+FILE_MAXFILE]; - char numstr[32]; - - /* calculate current filename */ - counter++; - counter= counter % MAXUNDO; - - sprintf(numstr, "%d.blend", counter); - BLI_make_file_string("/", tstr, U.tempdir, numstr); - - success= BLO_write_file(tstr, G.fileflags, &err); - - strcpy(curundo->str, tstr); - } - else { - MemFile *prevfile=NULL; - char *err; - - if(curundo->prev) prevfile= &(curundo->prev->memfile); - - success= BLO_write_file_mem(prevfile, &curundo->memfile, G.fileflags, &err); - - } -} - -/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ -void BIF_undo_step(int step) -{ - - if(step==1) { - /* curundo should never be NULL, after restart or load file it should call undo_save */ - if(curundo==NULL || curundo->prev==NULL) error("No undo available"); - else { - printf("undo %s\n", curundo->name); - curundo= curundo->prev; - read_undosave(curundo); - } - } - else { - - /* curundo has to remain current situation! */ - - if(curundo==NULL || curundo->next==NULL) error("No redo available"); - else { - read_undosave(curundo->next); - curundo= curundo->next; - printf("redo %s\n", curundo->name); - } - } -} - -void BIF_reset_undo(void) -{ - UndoElem *uel; - - uel= undobase.first; - while(uel) { - BLO_free_memfile(&uel->memfile); - uel= uel->next; - } - - BLI_freelistN(&undobase); - curundo= NULL; -} - - - |