Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 22 Nov 2018 04:16:45 +0000 (15:16 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 22 Nov 2018 04:16:45 +0000 (15:16 +1100)
1  2 
source/blender/blenkernel/BKE_blendfile.h
source/blender/blenkernel/intern/blender_undo.c
source/blender/blenkernel/intern/blendfile.c
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/undofile.c
source/blender/editors/render/render_preview.c
source/blender/windowmanager/intern/wm_files.c

index a00ad5ff05ffe80fc1a825dc52ddea0db1a3df6e,441687c1c01c43dae39ee929bda67c5bb5671ac0..fac3685f7b1f2cb73de4565b22f33686bd61d4ef
  #include "BKE_main.h"
  
  #include "BLO_undofile.h"
+ #include "BLO_readfile.h"
  #include "BLO_writefile.h"
  
 +#include "DEG_depsgraph.h"
 +
  /* -------------------------------------------------------------------- */
  
  /** \name Global Undo
index 5a975402c9073ef267ae30227febcacda2b78b27,c6cb8a412fef0ba78d467bb72c0afc867249ea7b..cc42fe71579fcc4f0ef8235e13d598ae7ea170fe
@@@ -414,11 -392,11 +417,11 @@@ bool BKE_blendfile_read_from_memory
  {
        BlendFileData *bfd;
  
-       bfd = BLO_read_from_memory(filebuf, filelength, reports, skip_flags);
+       bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
        if (bfd) {
                if (update_defaults)
 -                      BLO_update_defaults_startup_blend(bfd->main);
 +                      BLO_update_defaults_startup_blend(bfd->main, NULL);
-               setup_app_data(C, bfd, "<memory2>", reports);
+               setup_app_data(C, bfd, "<memory2>", params->is_startup, reports);
        }
        else {
                BKE_reports_prepend(reports, "Loading failed: ");
@@@ -561,54 -543,6 +568,54 @@@ bool BKE_blendfile_userdef_write_app_te
        return ok;
  }
  
-               bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_USERDEF);
 +WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, const void *filebuf, int filelength, ReportList *reports)
 +{
 +      BlendFileData *bfd;
 +      WorkspaceConfigFileData *workspace_config = NULL;
 +
 +      if (filepath) {
-               bfd = BLO_read_from_memory(filebuf, filelength, reports, BLO_READ_SKIP_USERDEF);
++              bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_USERDEF, reports);
 +      }
 +      else {
++              bfd = BLO_read_from_memory(filebuf, filelength, BLO_READ_SKIP_USERDEF, reports);
 +      }
 +
 +      if (bfd) {
 +              workspace_config = MEM_mallocN(sizeof(*workspace_config), __func__);
 +              workspace_config->main = bfd->main;
 +              workspace_config->workspaces = bfd->main->workspaces;
 +
 +              MEM_freeN(bfd);
 +      }
 +
 +      return workspace_config;
 +}
 +
 +bool BKE_blendfile_workspace_config_write(Main *bmain, const char *filepath, ReportList *reports)
 +{
 +      int fileflags = G.fileflags & ~(G_FILE_NO_UI | G_FILE_HISTORY);
 +      bool retval = false;
 +
 +      BKE_blendfile_write_partial_begin(bmain);
 +
 +      for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
 +              BKE_blendfile_write_partial_tag_ID(&workspace->id, true);
 +      }
 +
 +      if (BKE_blendfile_write_partial(bmain, filepath, fileflags, reports)) {
 +              retval = true;
 +      }
 +
 +      BKE_blendfile_write_partial_end(bmain);
 +
 +      return retval;
 +}
 +
 +void BKE_blendfile_workspace_config_data_free(WorkspaceConfigFileData *workspace_config)
 +{
 +      BKE_main_free(workspace_config->main);
 +      MEM_freeN(workspace_config);
 +}
  
  /** \} */
  
index ef02e7d7034e840dc4d520b7fbc7a3c81a34787a,5a1c479f45050e802072d72f728bc13cc4ff2786..df8cc164869f0ad539d1f0359a132d881049be0a
@@@ -75,12 -72,10 +75,16 @@@ typedef struct BlendFileData 
        eBlenFileType type;
  } BlendFileData;
  
 +typedef struct WorkspaceConfigFileData {
 +      struct Main *main; /* has to be freed when done reading file data */
 +
 +      struct ListBase workspaces;
 +} WorkspaceConfigFileData;
 +
+ struct BlendFileReadParams {
+       uint skip_flags : 2;  /* eBLOReadSkip */
+       uint is_startup : 1;
+ };
  
  /* skip reading some data-block types (may want to skip screen data too). */
  typedef enum eBLOReadSkip {