From f9fbbd8f8015e0b05c4dbe1052018698bf96872d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 May 2023 16:31:06 +1000 Subject: [PATCH] Cleanup: expand on code-comments Rename layout_old to layout_ref as the layout is a reference (the old layout has been freed). Also use boolean for save_copy argument. --- .../blender/blenkernel/intern/image_save.cc | 5 +++-- source/blender/sequencer/intern/effects.c | 6 +++++- .../blender/windowmanager/intern/wm_files.cc | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 83e32c39084..05739ed2e75 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -267,7 +267,7 @@ static void image_save_post(ReportList *reports, ImBuf *ibuf, int ok, const ImageSaveOptions *opts, - int save_copy, + const bool save_copy, const char *filepath, bool *r_colorspace_changed) { @@ -350,7 +350,8 @@ static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) /** * \return success. - * \note `ima->filepath` and `ibuf->filepath` should end up the same. + * \note `ima->filepath` and `ibuf->filepath` will reference the same path + * (although `ima->filepath` may be blend-file relative). * \note for multi-view the first `ibuf` is important to get the settings. */ static bool image_save_single(ReportList *reports, diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 624eb3a27e4..c6e84e9d0a7 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -3232,7 +3232,11 @@ void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user) if (vfont->packedfile != NULL) { PackedFile *pf = vfont->packedfile; /* Create a name that's unique between library data-blocks to avoid loading - * a font per strip which will load fonts many times. */ + * a font per strip which will load fonts many times. + * + * WARNING: this isn't fool proof! + * The #VFont may be renamed which will cause this to load multiple times, + * in practice this isn't so likely though. */ char name[MAX_ID_FULL_NAME]; BKE_id_full_name_get(name, &vfont->id, 0); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index f8eb81b0b34..0394f44bf93 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -269,6 +269,15 @@ static void wm_window_substitute_old(wmWindowManager *oldwm, win->posy = oldwin->posy; } +/** + * Support loading older files without multiple windows (pre 2.5), + * in this case the #bScreen from the users file should be used but the current + * windows (from `current_wm_list` are kept). + * + * As the original file did not have multiple windows, duplicate the layout into each window. + * An alternative solution could also be to close all windows except the first however this is + * enough of a corner case that it's the current behavior is acceptable. + */ static void wm_window_match_keep_current_wm(const bContext *C, ListBase *current_wm_list, const bool load_ui, @@ -286,7 +295,7 @@ static void wm_window_match_keep_current_wm(const bContext *C, LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace; - WorkSpaceLayout *layout_old = BKE_workspace_layout_find_global(bmain, screen, &workspace); + WorkSpaceLayout *layout_ref = BKE_workspace_layout_find_global(bmain, screen, &workspace); BKE_workspace_active_set(win->workspace_hook, workspace); win->scene = CTX_data_scene(C); @@ -295,11 +304,13 @@ static void wm_window_match_keep_current_wm(const bContext *C, WM_window_set_active_screen(win, workspace, screen); } else { -#if 0 /* NOTE(@ideasman42): The screen referenced from the window has been freed, see: 107525. */ - WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); +#if 0 + /* NOTE(@ideasman42): The screen referenced from the window has been freed, + * see: #107525. */ + WorkSpaceLayout *layout_ref = WM_window_get_active_layout(win); #endif WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( - bmain, workspace, layout_old, win); + bmain, workspace, layout_ref, win); WM_window_set_active_layout(win, workspace, layout_new); }