Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/blender_undo.c')
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c116
1 files changed, 57 insertions, 59 deletions
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index dd9be07be5d..6c077ac75ba 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -22,16 +22,16 @@
*/
#ifndef _WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> // for read close
#else
-# include <io.h> // for open close read
+# include <io.h> // for open close read
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
-#include <fcntl.h> /* for open */
+#include <fcntl.h> /* for open */
#include <errno.h>
#include "MEM_guardedalloc.h"
@@ -43,7 +43,7 @@
#include "BLI_utildefines.h"
#include "BKE_appdir.h"
-#include "BKE_blender_undo.h" /* own include */
+#include "BKE_blender_undo.h" /* own include */
#include "BKE_blendfile.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -59,79 +59,77 @@
/** \name Global Undo
* \{ */
-#define UNDO_DISK 0
+#define UNDO_DISK 0
bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C)
{
- Main *bmain = CTX_data_main(C);
- char mainstr[sizeof(bmain->name)];
- int success = 0, fileflags;
-
- BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
-
- fileflags = G.fileflags;
- G.fileflags |= G_FILE_NO_UI;
-
- if (UNDO_DISK) {
- success = (BKE_blendfile_read(C, mfu->filename, NULL, 0) != BKE_BLENDFILE_READ_FAIL);
- }
- else {
- success = BKE_blendfile_read_from_memfile(
- C, &mfu->memfile,
- &(const struct BlendFileReadParams){0},
- NULL);
- }
-
- /* Restore, bmain has been re-allocated. */
- bmain = CTX_data_main(C);
- BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
- G.fileflags = fileflags;
-
- if (success) {
- /* important not to update time here, else non keyed transforms are lost */
- DEG_on_visible_update(bmain, false);
- }
-
- return success;
+ Main *bmain = CTX_data_main(C);
+ char mainstr[sizeof(bmain->name)];
+ int success = 0, fileflags;
+
+ BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
+
+ fileflags = G.fileflags;
+ G.fileflags |= G_FILE_NO_UI;
+
+ if (UNDO_DISK) {
+ success = (BKE_blendfile_read(C, mfu->filename, NULL, 0) != BKE_BLENDFILE_READ_FAIL);
+ }
+ else {
+ success = BKE_blendfile_read_from_memfile(
+ C, &mfu->memfile, &(const struct BlendFileReadParams){0}, NULL);
+ }
+
+ /* Restore, bmain has been re-allocated. */
+ bmain = CTX_data_main(C);
+ BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
+ G.fileflags = fileflags;
+
+ if (success) {
+ /* important not to update time here, else non keyed transforms are lost */
+ DEG_on_visible_update(bmain, false);
+ }
+
+ return success;
}
MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
{
- MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__);
+ MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__);
- /* disk save version */
- if (UNDO_DISK) {
- static int counter = 0;
- char filename[FILE_MAX];
- char numstr[32];
- int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
+ /* disk save version */
+ if (UNDO_DISK) {
+ static int counter = 0;
+ char filename[FILE_MAX];
+ char numstr[32];
+ int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
- /* Calculate current filename. */
- counter++;
- counter = counter % U.undosteps;
+ /* Calculate current filename. */
+ counter++;
+ counter = counter % U.undosteps;
- BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
- BLI_make_file_string("/", filename, BKE_tempdir_session(), numstr);
+ BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
+ BLI_make_file_string("/", filename, BKE_tempdir_session(), numstr);
- /* success = */ /* UNUSED */ BLO_write_file(bmain, filename, fileflags, NULL, NULL);
+ /* success = */ /* UNUSED */ BLO_write_file(bmain, filename, fileflags, NULL, NULL);
- BLI_strncpy(mfu->filename, filename, sizeof(mfu->filename));
- }
- else {
- MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : NULL;
- /* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, G.fileflags);
- mfu->undo_size = mfu->memfile.size;
- }
+ BLI_strncpy(mfu->filename, filename, sizeof(mfu->filename));
+ }
+ else {
+ MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : NULL;
+ /* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, G.fileflags);
+ mfu->undo_size = mfu->memfile.size;
+ }
- bmain->is_memfile_undo_written = true;
+ bmain->is_memfile_undo_written = true;
- return mfu;
+ return mfu;
}
void BKE_memfile_undo_free(MemFileUndoData *mfu)
{
- BLO_memfile_free(&mfu->memfile);
- MEM_freeN(mfu);
+ BLO_memfile_free(&mfu->memfile);
+ MEM_freeN(mfu);
}
/** \} */