Fix a few unintended changes with new default startup.blend.

This commit is contained in:
Brecht Van Lommel 2018-08-21 15:21:53 +02:00
parent f1f3360696
commit df6cd591f8
3 changed files with 59 additions and 16 deletions

View 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 *));

View 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) {

View File

@ -25,30 +25,24 @@
* \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);
}
}
}