Fix a few unintended changes with new default startup.blend.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 21 Aug 2018 13:21:53 +0000 (15:21 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 21 Aug 2018 16:39:44 +0000 (18:39 +0200)
source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/intern/screen.c
source/blender/blenloader/intern/versioning_defaults.c

index c74170becb4045682e0a96fa397892166e8894b0..acf175b5ced136f84dd3fe76a717149e6dce46e3 100644 (file)
@@ -325,6 +325,7 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
 /* area/regions */
 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
 void            BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
+void            BKE_area_region_panels_free(struct ListBase *panels);
 void            BKE_screen_area_free(struct ScrArea *sa);
 /* Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
 void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
index c107bb04e6e83b003fc5df70f064ab3f584dc671..58a47dc2822ba0875c2ee7c2dd9b83f26ba3cbe0 100644 (file)
@@ -361,7 +361,7 @@ void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *)
        region_free_gizmomap_callback = callback;
 }
 
-static void panel_list_free(ListBase *lb)
+void BKE_area_region_panels_free(ListBase *lb)
 {
        Panel *pa, *pa_next;
        for (pa = lb->first; pa; pa = pa_next) {
@@ -369,9 +369,10 @@ static void panel_list_free(ListBase *lb)
                if (pa->activedata) {
                        MEM_freeN(pa->activedata);
                }
-               panel_list_free(&pa->children);
-               MEM_freeN(pa);
+               BKE_area_region_panels_free(&pa->children);
        }
+
+       BLI_freelistN(lb);
 }
 
 /* not region itself */
@@ -396,7 +397,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
                ar->v2d.tab_offset = NULL;
        }
 
-       panel_list_free(&ar->panels);
+       BKE_area_region_panels_free(&ar->panels);
 
        for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
                if (uilst->dyn_data) {
index cc937edf6ab875a54182e672dacdfe00ad69a99f..e6f8e70f70b1f36146fe54f27a5302192b3753d6 100644 (file)
  *  \ingroup blenloader
  */
 
+#include "MEM_guardedalloc.h"
+
 #include "BLI_utildefines.h"
 #include "BLI_listbase.h"
 #include "BLI_math.h"
 #include "BLI_string.h"
 
-#include "DNA_camera_types.h"
-#include "DNA_brush_types.h"
-#include "DNA_freestyle_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_linestyle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_material_types.h"
 #include "DNA_object_types.h"
 #include "DNA_workspace_types.h"
 
-#include "BKE_brush.h"
-#include "BKE_library.h"
+#include "BKE_layer.h"
 #include "BKE_main.h"
-#include "BKE_scene.h"
-#include "BKE_workspace.h"
+#include "BKE_node.h"
+#include "BKE_screen.h"
 
 #include "BLO_readfile.h"
 
@@ -86,7 +80,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                for (ScrArea *area = screen->areabase.first; area; area = area->next) {
                        for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
                                /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
-                               BLI_freelistN(&ar->panels);
+                               BKE_area_region_panels_free(&ar->panels);
 
                                /* some toolbars have been saved as initialized,
                                 * we don't want them to have odd zoom-level or scrolling set, see: T47047 */
@@ -94,6 +88,53 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                                        ar->v2d.flag &= ~V2D_IS_INITIALISED;
                                }
                        }
+
+                       if (area->spacetype == SPACE_FILE) {
+                               SpaceFile *sfile = area->spacedata.first;
+
+                               if (sfile->params) {
+                                       if (STREQ(screen->id.name, "SRDefault.003")) {
+                                               /* Shading. */
+                                               sfile->params->filter = FILE_TYPE_FOLDER |
+                                                                       FILE_TYPE_IMAGE;
+                                       }
+                                       else {
+                                               /* Video Editing. */
+                                               sfile->params->filter = FILE_TYPE_FOLDER |
+                                                                       FILE_TYPE_IMAGE |
+                                                                       FILE_TYPE_MOVIE |
+                                                                       FILE_TYPE_SOUND;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+               BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+
+               scene->r.cfra = 1.0f;
+
+               /* Don't enable compositing nodes. */
+               if (scene->nodetree) {
+                       ntreeFreeTree(scene->nodetree);
+                       MEM_freeN(scene->nodetree);
+                       scene->nodetree = NULL;
+                       scene->use_nodes = false;
+               }
+
+               /* Select only cube by default. */
+               for (ViewLayer *layer = scene->view_layers.first; layer; layer = layer->next) {
+                       for (Base *base = layer->object_bases.first; base; base = base->next) {
+                               if (STREQ(base->object->id.name + 2, "Cube")) {
+                                       base->flag |= BASE_SELECTED;
+                               }
+                               else {
+                                       base->flag &= ~BASE_SELECTED;
+                               }
+                       }
+
+                       BKE_layer_collection_sync(scene, layer);
                }
        }
 }