Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| /* In case we are given a valid thumbnail data, just generate image from it. */ | /* In case we are given a valid thumbnail data, just generate image from it. */ | ||||
| ibuf_thumb = BKE_main_thumbnail_to_imbuf(NULL, thumb); | ibuf_thumb = BKE_main_thumbnail_to_imbuf(NULL, thumb); | ||||
| } | } | ||||
| else if (BLI_thread_is_main()) { | else if (BLI_thread_is_main()) { | ||||
| int file_preview_type = U.file_preview_type; | int file_preview_type = U.file_preview_type; | ||||
| if (file_preview_type == USER_FILE_PREVIEW_AUTO) { | if (file_preview_type == USER_FILE_PREVIEW_AUTO) { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| bool do_render = (scene != NULL && scene->camera != NULL && | bScreen *screen = CTX_wm_screen(C); | ||||
| (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) != NULL)); | bool do_render = (scene != NULL && scene->camera != NULL && screen != NULL && | ||||
| (BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0) != NULL)); | |||||
| file_preview_type = do_render ? USER_FILE_PREVIEW_CAMERA : USER_FILE_PREVIEW_SCREENSHOT; | file_preview_type = do_render ? USER_FILE_PREVIEW_CAMERA : USER_FILE_PREVIEW_SCREENSHOT; | ||||
| } | } | ||||
| switch (file_preview_type) { | switch (file_preview_type) { | ||||
| case USER_FILE_PREVIEW_SCREENSHOT: { | case USER_FILE_PREVIEW_SCREENSHOT: { | ||||
| ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb); | ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb); | ||||
| break; | break; | ||||
| } | } | ||||
| case USER_FILE_PREVIEW_CAMERA: { | case USER_FILE_PREVIEW_CAMERA: { | ||||
| ibuf_thumb = blend_file_thumb_from_camera( | ibuf_thumb = blend_file_thumb_from_camera( | ||||
| C, CTX_data_scene(C), CTX_wm_screen(C), &thumb); | C, CTX_data_scene(C), CTX_wm_screen(C), &thumb); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| BLI_assert_unreachable(); | BLI_assert_unreachable(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* operator now handles overwrite checks */ | /* operator now handles overwrite checks */ | ||||
| if (G.fileflags & G_FILE_AUTOPACK) { | if (G.fileflags & G_FILE_AUTOPACK) { | ||||
| BKE_packedfile_pack_all(bmain, reports, false); | BKE_packedfile_pack_all(bmain, reports, false); | ||||
| } | } | ||||
Severin: I'd rather have a variable and avoid calling `CTX_wm_screen(C)` twice. Not a big deal, but it… | |||||
| ED_editors_flush_edits(bmain); | ED_editors_flush_edits(bmain); | ||||
| /* First time saving. */ | /* First time saving. */ | ||||
| /* XXX(ton): temp solution to solve bug, real fix coming. */ | /* XXX(ton): temp solution to solve bug, real fix coming. */ | ||||
| if ((BKE_main_blendfile_path(bmain)[0] == '\0') && (use_save_as_copy == false)) { | if ((BKE_main_blendfile_path(bmain)[0] == '\0') && (use_save_as_copy == false)) { | ||||
| STRNCPY(bmain->filepath, filepath); | STRNCPY(bmain->filepath, filepath); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines | |||||
I'd rather have a variable and avoid calling CTX_wm_screen(C) twice. Not a big deal, but it does some unnecessary work, possibly including a Python dictionary lookup.