Refactor: move Screen .blend data read to blenkernel

Ref T76372.
This commit is contained in:
Jacques Lucke 2020-11-06 18:37:52 +01:00
parent 1762d5f43a
commit 992b8f6f5f
Notes: blender-bot 2023-02-21 17:59:30 +01:00
Referenced by issue #76372, Blenloader Decentralization
3 changed files with 22 additions and 20 deletions

View File

@ -465,6 +465,7 @@ void BKE_screen_view3d_do_versions_250(struct View3D *v3d, ListBase *regions);
void BKE_screen_area_blend_read_lib(struct BlendLibReader *reader,
struct ID *parent_id,
struct ScrArea *area);
bool BKE_screen_blend_read_lib(struct BlendDataReader *reader, struct bScreen *screen);
#ifdef __cplusplus
}

View File

@ -254,6 +254,26 @@ static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_addre
}
}
/* Cannot use IDTypeInfo callback yet, because of the return value. */
bool BKE_screen_blend_read_lib(BlendDataReader *reader, bScreen *screen)
{
bool success = true;
screen->regionbase.first = screen->regionbase.last = NULL;
screen->context = NULL;
screen->active_region = NULL;
BLO_read_data_address(reader, &screen->preview);
BKE_previewimg_blend_read(reader, screen->preview);
if (!BKE_screen_area_map_blend_read_data(reader, AREAMAP_FROM_SCREEN(screen))) {
printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
success = false;
}
return success;
}
/* note: file read without screens option G_FILE_NO_UI;
* check lib pointers in call below */
static void screen_blend_read_lib(BlendLibReader *reader, ID *id)

View File

@ -3042,25 +3042,6 @@ void blo_lib_link_restore(Main *oldmain,
BKE_main_idmap_destroy(id_map);
}
static bool direct_link_screen(BlendDataReader *reader, bScreen *screen)
{
bool success = true;
screen->regionbase.first = screen->regionbase.last = NULL;
screen->context = NULL;
screen->active_region = NULL;
BLO_read_data_address(reader, &screen->preview);
BKE_previewimg_blend_read(reader, screen->preview);
if (!BKE_screen_area_map_blend_read_data(reader, AREAMAP_FROM_SCREEN(screen))) {
printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
success = false;
}
return success;
}
/** \} */
/* -------------------------------------------------------------------- */
@ -3305,7 +3286,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
switch (GS(id->name)) {
case ID_SCR:
success = direct_link_screen(&reader, (bScreen *)id);
success = BKE_screen_blend_read_lib(&reader, (bScreen *)id);
break;
case ID_LI:
direct_link_library(fd, (Library *)id, main);