From 05a9dbf8ef8adbc68e6032c94a157c25bf2db720 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 18 May 2023 10:36:15 -0700 Subject: [PATCH 01/11] Updated to current state of main, some cleanup. --- scripts/startup/bl_ui/space_topbar.py | 40 +-- .../editors/space_outliner/outliner_edit.cc | 299 ++++++++++++++++++ .../editors/space_outliner/outliner_intern.hh | 1 + .../editors/space_outliner/outliner_ops.cc | 1 + 4 files changed, 302 insertions(+), 39 deletions(-) diff --git a/scripts/startup/bl_ui/space_topbar.py b/scripts/startup/bl_ui/space_topbar.py index 53cd5072c9a..d1ab9e252dd 100644 --- a/scripts/startup/bl_ui/space_topbar.py +++ b/scripts/startup/bl_ui/space_topbar.py @@ -228,43 +228,6 @@ class TOPBAR_MT_blender(Menu): layout.menu("TOPBAR_MT_blender_system") -class TOPBAR_MT_file_cleanup(Menu): - bl_label = "Clean Up" - - def draw(self, _context): - layout = self.layout - layout.separator() - - props = layout.operator("outliner.orphans_purge", text="Unused Data-Blocks") - props.do_local_ids = True - props.do_linked_ids = True - props.do_recursive = False - props = layout.operator("outliner.orphans_purge", text="Recursive Unused Data-Blocks") - props.do_local_ids = True - props.do_linked_ids = True - props.do_recursive = True - - layout.separator() - props = layout.operator("outliner.orphans_purge", text="Unused Linked Data-Blocks") - props.do_local_ids = False - props.do_linked_ids = True - props.do_recursive = False - props = layout.operator("outliner.orphans_purge", text="Recursive Unused Linked Data-Blocks") - props.do_local_ids = False - props.do_linked_ids = True - props.do_recursive = True - - layout.separator() - props = layout.operator("outliner.orphans_purge", text="Unused Local Data-Blocks") - props.do_local_ids = True - props.do_linked_ids = False - props.do_recursive = False - props = layout.operator("outliner.orphans_purge", text="Recursive Unused Local Data-Blocks") - props.do_local_ids = True - props.do_linked_ids = False - props.do_recursive = True - - class TOPBAR_MT_file(Menu): bl_label = "File" @@ -303,7 +266,7 @@ class TOPBAR_MT_file(Menu): layout.separator() layout.menu("TOPBAR_MT_file_external_data") - layout.menu("TOPBAR_MT_file_cleanup") + layout.operator("outliner.orphans_cleanup", text="Clean Up...") layout.separator() @@ -948,7 +911,6 @@ classes = ( TOPBAR_MT_file_import, TOPBAR_MT_file_export, TOPBAR_MT_file_external_data, - TOPBAR_MT_file_cleanup, TOPBAR_MT_file_previews, TOPBAR_MT_edit, TOPBAR_MT_render, diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 6b0f1669e8a..4873dffcfd7 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2245,6 +2245,305 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) "data-blocks remain after execution"); } +static void wm_block_orphans_cancel(bContext *C, void *arg_block, void *arg_data) +{ + UNUSED_VARS_NDEBUG(arg_data); + UI_popup_block_close(C, CTX_wm_window(C), (uiBlock *)arg_block); +} + +static void wm_block_orphans_cancel_button(uiBlock *block) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Cancel"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_orphans_cancel, block, NULL); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); + UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); +} + +static char orphans_purge_do_local = true; +static char orphans_purge_do_linked = false; +static char orphans_purge_do_recursive = false; + +static void wm_block_orphans_purge(bContext *C, void *arg_block, void *arg_data) +{ + wmOperator *op = (wmOperator *)arg_data; + Main *bmain = CTX_data_main(C); + int num_tagged[INDEX_ID_MAX] = {0}; + + /* Tag all IDs to delete. */ + BKE_lib_query_unused_ids_tag(bmain, + LIB_TAG_DOIT, + orphans_purge_do_local, + orphans_purge_do_linked, + orphans_purge_do_recursive, + num_tagged); + + if (num_tagged[INDEX_ID_NULL] == 0) { + BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + } + else { + BKE_id_multi_tagged_delete(bmain); + BKE_reportf(op->reports, RPT_INFO, "Deleted %d data-block(s)", num_tagged[INDEX_ID_NULL]); + DEG_relations_tag_update(bmain); + WM_event_add_notifier(C, NC_ID | NA_REMOVED, nullptr); + /* Force full redraw of the UI. */ + WM_main_add_notifier(NC_WINDOW, nullptr); + } + + UI_popup_block_close(C, CTX_wm_window(C), (uiBlock *)arg_block); +} + +static void wm_block_orphans_keep(bContext *C, void *arg_block, void *arg_data) +{ + wmOperator *op = (wmOperator *)arg_data; + Main *bmain = CTX_data_main(C); + int num_tagged[INDEX_ID_MAX] = {0}; + + /* Tag all IDs that are unused. */ + BKE_lib_query_unused_ids_tag(bmain, + LIB_TAG_DOIT, + orphans_purge_do_local, + orphans_purge_do_linked, + orphans_purge_do_recursive, + num_tagged); + + if (num_tagged[INDEX_ID_NULL] == 0) { + BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks"); + } + else { + ListBase *lbarray[INDEX_ID_MAX]; + int a; + a = set_listbasepointers(bmain, lbarray); + while (a--) { + LISTBASE_FOREACH (ID *, id, lbarray[a]) { + if (id->tag & LIB_TAG_DOIT) { + id_fake_user_set(id); + } + } + } + + BKE_reportf(op->reports, RPT_INFO, "Set fake user on %d data-block(s)", num_tagged[INDEX_ID_NULL]); + DEG_relations_tag_update(bmain); + WM_event_add_notifier(C, NC_ID | NA_EDITED, nullptr); + /* Force full redraw of the UI. */ + WM_main_add_notifier(NC_WINDOW, nullptr); + } + + UI_popup_block_close(C, CTX_wm_window(C), (uiBlock *)arg_block); +} + +static void wm_block_orphans_manage(bContext *C, void *arg_block, void *arg_data) +{ + wmWindow *win = CTX_wm_window(C); + if (WM_window_open(C, + IFACE_("Manage Unused Data"), + 0, + 0, + 500 * UI_SCALE_FAC, + 500 * UI_SCALE_FAC, + SPACE_OUTLINER, + false, + false, + true, + WIN_ALIGN_PARENT_CENTER) != NULL) { + SpaceOutliner *soutline = (SpaceOutliner *)CTX_wm_area(C)->spacedata.first; + soutline->outlinevis = SO_ID_ORPHANS; + } + UI_popup_block_close(C, win, (uiBlock *)arg_block); +} + +static void wm_block_orphans_purge_button(uiBlock *block, wmOperator *op) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Delete"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_orphans_purge, block, op); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); +} + +static void wm_block_orphans_keep_button(uiBlock *block, wmOperator *op) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Protect"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_orphans_keep, block, op); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); +} + +static void wm_block_orphans_manage_button(uiBlock *block, wmOperator *op) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Manage"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_orphans_manage, block, op); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); +} + +static void orphan_desc(bContext *C, DynStr *desc_r, bool local, bool linked, bool recursive) +{ + Main *bmain = CTX_data_main(C); + int num_tagged[INDEX_ID_MAX] = {0}; + + BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, local, linked, recursive, num_tagged); + + bool is_first = true; + for (int i = 0; i < INDEX_ID_MAX - 2; i++) { + if (num_tagged[i] != 0) { + if (!is_first) { + BLI_dynstr_append(desc_r, ", "); + } + else { + is_first = false; + } + BLI_dynstr_appendf( + desc_r, + "%d %s", + num_tagged[i], + num_tagged[i] > 1 ? + TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : + TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); + } + } + if (BLI_dynstr_get_len(desc_r) == 0) { + BLI_dynstr_append(desc_r, "Nothing"); + } +} + +static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, void *arg) +{ + wmOperator *op = (wmOperator *)arg; + uiBlock *block = UI_block_begin(C, region, "orphans_remove_popup", UI_EMBOSS); + UI_block_flag_enable( + block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT); + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); + + uiLayout *layout = uiItemsAlertBox(block, 40, ALERT_ICON_WARNING); + + /* Title. */ + uiItemL_ex(layout, TIP_("Clean Up Unused Data in this File"), 0, true, false); + + uiItemS(layout); + + char text[1024]; + DynStr *dyn_str = BLI_dynstr_new(); + orphan_desc(C, dyn_str, true, false, false); + BLI_snprintf(text, 1024, "Local (%s)", BLI_dynstr_get_cstring(dyn_str)); + + uiDefButBitC(block, + UI_BTYPE_CHECKBOX, + 1, + 0, + text, + 0, + 0, + 0, + UI_UNIT_Y, + &orphans_purge_do_local, + 0, + 0, + 0, + 0, + "Delete unused local data-blocks"); + + BLI_dynstr_clear(dyn_str); + orphan_desc(C, dyn_str, false, true, false); + BLI_snprintf(text, 1024, "Linked (%s)", BLI_dynstr_get_cstring(dyn_str)); + + uiDefButBitC(block, + UI_BTYPE_CHECKBOX, + 1, + 0, + text, + 0, + 0, + 0, + UI_UNIT_Y, + &orphans_purge_do_linked, + 0, + 0, + 0, + 0, + "Delete unused linked data-blocks"); + + BLI_dynstr_clear(dyn_str); + orphan_desc(C, dyn_str, false, false, true); + BLI_snprintf(text, 1024, "Indirectly Unused (%s)", BLI_dynstr_get_cstring(dyn_str)); + + uiDefButBitC(block, + UI_BTYPE_CHECKBOX, + 1, + 0, + text, + 0, + 0, + 0, + UI_UNIT_Y, + &orphans_purge_do_recursive, + 0, + 0, + 0, + 0, + "Recursively check for indirectly unused data-blocks, ensuring that no orphaned " + "data-blocks remain after execution"); + + BLI_dynstr_free(dyn_str); + + uiItemS_ex(layout, 2.0f); + + /* Buttons. */ +#ifdef _WIN32 + const bool windows_layout = true; +#else + const bool windows_layout = false; +#endif + + uiLayout *split = uiLayoutSplit(layout, 0.0f, true); + uiLayoutSetScaleY(split, 1.2f); + + if (windows_layout) { + /* Windows standard layout. */ + uiLayoutColumn(split, false); + wm_block_orphans_purge_button(block, op); + uiLayoutColumn(split, false); + wm_block_orphans_keep_button(block, op); + uiLayoutColumn(split, false); + wm_block_orphans_manage_button(block, op); + uiLayoutColumn(split, false); + wm_block_orphans_cancel_button(block); + } + else { + /* Non-Windows layout (macOS and Linux). */ + uiLayoutColumn(split, false); + wm_block_orphans_cancel_button(block); + uiLayoutColumn(split, false); + wm_block_orphans_manage_button(block, op); + uiLayoutColumn(split, false); + wm_block_orphans_keep_button(block, op); + uiLayoutColumn(split, false); + wm_block_orphans_purge_button(block, op); + } + + UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC); + return block; +} + +static int outliner_orphans_cleanup_exec(bContext *C, wmOperator *op) +{ + UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, op, NULL); + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot) +{ + /* identifiers */ + ot->idname = "OUTLINER_OT_orphans_cleanup"; + ot->name = "Clean Up Unused Data..."; + ot->description = "Clean Up Unused data-blocks in the file"; + + /* callbacks */ + ot->exec = outliner_orphans_cleanup_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + /** \} */ } // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index a8a5002761b..14b5f7e3aa1 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -505,6 +505,7 @@ void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot); void OUTLINER_OT_orphans_purge(struct wmOperatorType *ot); +void OUTLINER_OT_orphans_cleanup(struct wmOperatorType *ot); /* outliner_query.cc ---------------------------------------------- */ diff --git a/source/blender/editors/space_outliner/outliner_ops.cc b/source/blender/editors/space_outliner/outliner_ops.cc index ac99f5f774b..78f86e9aa04 100644 --- a/source/blender/editors/space_outliner/outliner_ops.cc +++ b/source/blender/editors/space_outliner/outliner_ops.cc @@ -59,6 +59,7 @@ void outliner_operatortypes() WM_operatortype_append(OUTLINER_OT_drivers_delete_selected); WM_operatortype_append(OUTLINER_OT_orphans_purge); + WM_operatortype_append(OUTLINER_OT_orphans_cleanup); WM_operatortype_append(OUTLINER_OT_parent_drop); WM_operatortype_append(OUTLINER_OT_parent_clear); -- 2.30.2 From 0cc6203cfdc2c66c18c7d0aa71d841576b5b8868 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 24 Aug 2023 10:18:15 -0700 Subject: [PATCH 02/11] Updated to the current state of main. --- source/blender/editors/space_outliner/outliner_edit.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index a74f6c70db3..6cb850b3782 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2264,7 +2264,7 @@ static void wm_block_orphans_cancel_button(uiBlock *block) { uiBut *but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, 0, IFACE_("Cancel"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); - UI_but_func_set(but, wm_block_orphans_cancel, block, NULL); + UI_but_func_set(but, wm_block_orphans_cancel, block, nullptr); UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); } @@ -2452,7 +2452,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo static int outliner_orphans_cleanup_exec(bContext *C, wmOperator *op) { - UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, op, NULL); + UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, op, nullptr); return OPERATOR_FINISHED; } -- 2.30.2 From 625b660aebceac259c84f40d3d602c72cb07dda4 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 12 Nov 2023 08:24:02 -0800 Subject: [PATCH 03/11] "Orphaned" -> "Unused". "data-block" -> "data" --- scripts/startup/bl_ui/space_topbar.py | 4 ++-- .../editors/space_outliner/outliner_edit.cc | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/startup/bl_ui/space_topbar.py b/scripts/startup/bl_ui/space_topbar.py index 5471f08d21b..8dfb081db36 100644 --- a/scripts/startup/bl_ui/space_topbar.py +++ b/scripts/startup/bl_ui/space_topbar.py @@ -237,8 +237,8 @@ class TOPBAR_MT_file_cleanup(Menu): def draw(self, _context): layout = self.layout layout.separator() - layout.operator("outliner.orphans_cleanup", text="Purge Unused Data-Blocks...") - layout.operator("outliner.orphans_manage", text="Manage Unused Data-Blocks...") + layout.operator("outliner.orphans_cleanup") + layout.operator("outliner.orphans_manage") class TOPBAR_MT_file(Menu): diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index a74baf185e8..afd22fcd0f9 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2285,11 +2285,11 @@ static void wm_block_orphans_purge(bContext *C, void *arg_block, void *arg_data) num_tagged); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + BKE_report(op->reports, RPT_INFO, "No unused data to purge"); } else { BKE_id_multi_tagged_delete(bmain); - BKE_reportf(op->reports, RPT_INFO, "Deleted %d data-block(s)", num_tagged[INDEX_ID_NULL]); + BKE_reportf(op->reports, RPT_INFO, "Deleted %d data block(s)", num_tagged[INDEX_ID_NULL]); DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_ID | NA_REMOVED, nullptr); /* Force full redraw of the UI. */ @@ -2348,7 +2348,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo uiLayout *layout = uiItemsAlertBox(block, 40, ALERT_ICON_WARNING); /* Title. */ - uiItemL_ex(layout, TIP_("Clean Up Unused Data in this File"), 0, true, false); + uiItemL_ex(layout, TIP_("Clean Up Unused Data in This File"), 0, true, false); uiItemS(layout); @@ -2371,7 +2371,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, 0, - "Delete unused local data-blocks"); + "Delete unused local data"); BLI_dynstr_clear(dyn_str); orphan_desc(C, dyn_str, false, true, false); @@ -2391,7 +2391,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, 0, - "Delete unused linked data-blocks"); + "Delete unused linked data"); BLI_dynstr_clear(dyn_str); orphan_desc(C, dyn_str, false, false, true); @@ -2411,8 +2411,8 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, 0, - "Recursively check for indirectly unused data-blocks, ensuring that no orphaned " - "data-blocks remain after execution"); + "Recursively check for indirectly unused data, ensuring that no orphaned data " + "remains after execution"); BLI_dynstr_free(dyn_str); @@ -2457,8 +2457,8 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot) { /* identifiers */ ot->idname = "OUTLINER_OT_orphans_cleanup"; - ot->name = "Clean Up Unused Data..."; - ot->description = "Clean Up Unused data-blocks in the file"; + ot->name = "Purge Unused Data..."; + ot->description = "Purge Unused data in the file"; /* callbacks */ ot->exec = outliner_orphans_cleanup_exec; @@ -2498,7 +2498,7 @@ void OUTLINER_OT_orphans_manage(wmOperatorType *ot) /* identifiers */ ot->idname = "OUTLINER_OT_orphans_manage"; ot->name = "Manage Unused Data..."; - ot->description = "Open a window to manage unused data-blocks"; + ot->description = "Open a window to manage unused data"; /* callbacks */ ot->exec = outliner_orphans_manage_exec; -- 2.30.2 From fca7a9ec25c6e92f47022eb10b660618dbc6aa42 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 20 Dec 2023 15:21:45 -0800 Subject: [PATCH 04/11] Mostly terminology changes --- .../editors/space_outliner/outliner_edit.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 6195f8ea884..45be615c578 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2111,7 +2111,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Purge Orphan Data-Blocks Operator +/** \name Remove Orphan Data-Blocks Operator * \{ */ static bool ed_operator_outliner_id_orphans_active(bContext *C) @@ -2140,12 +2140,12 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv RNA_int_set(op->ptr, "num_deleted", num_tagged[INDEX_ID_NULL]); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + BKE_report(op->reports, RPT_INFO, "No unused data-blocks to remove"); return OPERATOR_CANCELLED; } DynStr *dyn_str = BLI_dynstr_new(); - BLI_dynstr_appendf(dyn_str, TIP_("Purging %d unused data-blocks ("), num_tagged[INDEX_ID_NULL]); + BLI_dynstr_appendf(dyn_str, TIP_("Removing %d unused data-blocks ("), num_tagged[INDEX_ID_NULL]); bool is_first = true; for (int i = 0; i < INDEX_ID_MAX - 2; i++) { if (num_tagged[i] != 0) { @@ -2188,7 +2188,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + BKE_report(op->reports, RPT_INFO, "No unused data-blocks to remove"); return OPERATOR_CANCELLED; } } @@ -2218,8 +2218,8 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) { /* identifiers */ ot->idname = "OUTLINER_OT_orphans_purge"; - ot->name = "Purge All"; - ot->description = "Clear all orphaned data-blocks without any users from the file"; + ot->name = "Remove All"; + ot->description = "Remove all data-blocks without any users from the file"; /* callbacks */ ot->invoke = outliner_orphans_purge_invoke; @@ -2248,7 +2248,7 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) "do_recursive", false, "Recursive Delete", - "Recursively check for indirectly unused data-blocks, ensuring that no orphaned " + "Recursively check for indirectly unused data-blocks, ensuring that no unused " "data-blocks remain after execution"); } @@ -2285,7 +2285,7 @@ static void wm_block_orphans_purge(bContext *C, void *arg_block, void *arg_data) num_tagged); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No unused data to purge"); + BKE_report(op->reports, RPT_INFO, "No unused data to remove"); } else { BKE_id_multi_tagged_delete(bmain); @@ -2348,7 +2348,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo uiLayout *layout = uiItemsAlertBox(block, 40, ALERT_ICON_WARNING); /* Title. */ - uiItemL_ex(layout, TIP_("Clean Up Unused Data in This File"), 0, true, false); + uiItemL_ex(layout, TIP_("Remove Unused Data in This File"), 0, true, false); uiItemS(layout); @@ -2411,7 +2411,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, 0, - "Recursively check for indirectly unused data, ensuring that no orphaned data " + "Recursively check for indirectly unused data, ensuring that no unused data " "remains after execution"); BLI_dynstr_free(dyn_str); @@ -2457,8 +2457,8 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot) { /* identifiers */ ot->idname = "OUTLINER_OT_orphans_cleanup"; - ot->name = "Purge Unused Data..."; - ot->description = "Purge Unused data in the file"; + ot->name = "Remove Unused Data..."; + ot->description = "Remove Unused data in the file"; /* callbacks */ ot->exec = outliner_orphans_cleanup_exec; -- 2.30.2 From db344ea0329fb0c6ee67e054d58824e015f1e23b Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Jan 2024 15:38:42 -0800 Subject: [PATCH 05/11] Changes requested by review --- .../editors/space_outliner/outliner_edit.cc | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 45be615c578..e0353819013 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2111,7 +2111,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Remove Orphan Data-Blocks Operator +/** \name Purge Orphan Data-Blocks Operator * \{ */ static bool ed_operator_outliner_id_orphans_active(bContext *C) @@ -2140,12 +2140,12 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv RNA_int_set(op->ptr, "num_deleted", num_tagged[INDEX_ID_NULL]); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No unused data-blocks to remove"); + BKE_report(op->reports, RPT_INFO, "No unused data-blocks to purge"); return OPERATOR_CANCELLED; } DynStr *dyn_str = BLI_dynstr_new(); - BLI_dynstr_appendf(dyn_str, TIP_("Removing %d unused data-blocks ("), num_tagged[INDEX_ID_NULL]); + BLI_dynstr_appendf(dyn_str, TIP_("Purging %d unused data-blocks ("), num_tagged[INDEX_ID_NULL]); bool is_first = true; for (int i = 0; i < INDEX_ID_MAX - 2; i++) { if (num_tagged[i] != 0) { @@ -2188,7 +2188,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged); if (num_tagged[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No unused data-blocks to remove"); + BKE_report(op->reports, RPT_INFO, "No unused data-blocks to purge"); return OPERATOR_CANCELLED; } } @@ -2218,8 +2218,8 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) { /* identifiers */ ot->idname = "OUTLINER_OT_orphans_purge"; - ot->name = "Remove All"; - ot->description = "Remove all data-blocks without any users from the file"; + ot->name = "Purge All"; + ot->description = "Remove all unused data-blocks without any users from the file"; /* callbacks */ ot->invoke = outliner_orphans_purge_invoke; @@ -2266,22 +2266,26 @@ static void wm_block_orphans_cancel_button(uiBlock *block) UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); } -static char orphans_purge_do_local = true; -static char orphans_purge_do_linked = false; -static char orphans_purge_do_recursive = false; +struct OrphansPurgeData { + wmOperator *op = nullptr; + char local = true; + char linked = false; + char recursive = false; +}; static void wm_block_orphans_purge(bContext *C, void *arg_block, void *arg_data) { - wmOperator *op = (wmOperator *)arg_data; + OrphansPurgeData *purge_data = (OrphansPurgeData *)arg_data; + wmOperator *op = purge_data->op; Main *bmain = CTX_data_main(C); int num_tagged[INDEX_ID_MAX] = {0}; /* Tag all IDs to delete. */ BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, - orphans_purge_do_local, - orphans_purge_do_linked, - orphans_purge_do_recursive, + purge_data->local, + purge_data->linked, + purge_data->recursive, num_tagged); if (num_tagged[INDEX_ID_NULL] == 0) { @@ -2299,11 +2303,11 @@ static void wm_block_orphans_purge(bContext *C, void *arg_block, void *arg_data) UI_popup_block_close(C, CTX_wm_window(C), (uiBlock *)arg_block); } -static void wm_block_orphans_purge_button(uiBlock *block, wmOperator *op) +static void wm_block_orphans_purge_button(uiBlock *block, OrphansPurgeData *purge_data) { uiBut *but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, 0, IFACE_("Delete"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); - UI_but_func_set(but, wm_block_orphans_purge, block, op); + UI_but_func_set(but, wm_block_orphans_purge, block, purge_data); UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); } @@ -2339,7 +2343,8 @@ static void orphan_desc(bContext *C, DynStr *desc_r, bool local, bool linked, bo static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, void *arg) { - wmOperator *op = (wmOperator *)arg; + OrphansPurgeData *purge_data = (OrphansPurgeData *)arg; + wmOperator *op = purge_data->op; uiBlock *block = UI_block_begin(C, region, "orphans_remove_popup", UI_EMBOSS); UI_block_flag_enable( block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT); @@ -2348,14 +2353,14 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo uiLayout *layout = uiItemsAlertBox(block, 40, ALERT_ICON_WARNING); /* Title. */ - uiItemL_ex(layout, TIP_("Remove Unused Data in This File"), 0, true, false); + uiItemL_ex(layout, TIP_("Purge Unused Data From This File"), 0, true, false); uiItemS(layout); char text[1024]; DynStr *dyn_str = BLI_dynstr_new(); orphan_desc(C, dyn_str, true, false, false); - BLI_snprintf(text, 1024, "Local (%s)", BLI_dynstr_get_cstring(dyn_str)); + BLI_snprintf(text, 1024, "Local data: %s", BLI_dynstr_get_cstring(dyn_str)); uiDefButBitC(block, UI_BTYPE_CHECKBOX, @@ -2366,7 +2371,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, UI_UNIT_Y, - &orphans_purge_do_local, + &purge_data->local, 0, 0, 0, @@ -2375,7 +2380,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo BLI_dynstr_clear(dyn_str); orphan_desc(C, dyn_str, false, true, false); - BLI_snprintf(text, 1024, "Linked (%s)", BLI_dynstr_get_cstring(dyn_str)); + BLI_snprintf(text, 1024, "Linked data: %s", BLI_dynstr_get_cstring(dyn_str)); uiDefButBitC(block, UI_BTYPE_CHECKBOX, @@ -2386,7 +2391,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, UI_UNIT_Y, - &orphans_purge_do_linked, + &purge_data->linked, 0, 0, 0, @@ -2395,7 +2400,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo BLI_dynstr_clear(dyn_str); orphan_desc(C, dyn_str, false, false, true); - BLI_snprintf(text, 1024, "Indirectly Unused (%s)", BLI_dynstr_get_cstring(dyn_str)); + BLI_snprintf(text, 1024, "Include Indirectly Unused (recursive)"); uiDefButBitC(block, UI_BTYPE_CHECKBOX, @@ -2406,7 +2411,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, 0, UI_UNIT_Y, - &orphans_purge_do_recursive, + &purge_data->recursive, 0, 0, 0, @@ -2431,7 +2436,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo if (windows_layout) { /* Windows standard layout. */ uiLayoutColumn(split, false); - wm_block_orphans_purge_button(block, op); + wm_block_orphans_purge_button(block, purge_data); uiLayoutColumn(split, false); wm_block_orphans_cancel_button(block); } @@ -2440,7 +2445,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo uiLayoutColumn(split, false); wm_block_orphans_cancel_button(block); uiLayoutColumn(split, false); - wm_block_orphans_purge_button(block, op); + wm_block_orphans_purge_button(block, purge_data); } UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC); @@ -2449,7 +2454,9 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo static int outliner_orphans_cleanup_exec(bContext *C, wmOperator *op) { - UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, op, nullptr); + OrphansPurgeData *purge_data = MEM_new("orphans_purge_data"); + purge_data->op = op; + UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, purge_data, MEM_freeN); return OPERATOR_FINISHED; } @@ -2457,8 +2464,8 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot) { /* identifiers */ ot->idname = "OUTLINER_OT_orphans_cleanup"; - ot->name = "Remove Unused Data..."; - ot->description = "Remove Unused data in the file"; + ot->name = "Purge Unused Data..."; + ot->description = "Remove unused data from this file"; /* callbacks */ ot->exec = outliner_orphans_cleanup_exec; -- 2.30.2 From ebabf3442007458942c56aa2406d8c338ce3dd89 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Jan 2024 15:45:20 -0800 Subject: [PATCH 06/11] Capitalization. --- source/blender/editors/space_outliner/outliner_edit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index e0353819013..ad83a770d14 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2400,7 +2400,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo BLI_dynstr_clear(dyn_str); orphan_desc(C, dyn_str, false, false, true); - BLI_snprintf(text, 1024, "Include Indirectly Unused (recursive)"); + BLI_snprintf(text, 1024, "Include Indirectly Unused (Recursive)"); uiDefButBitC(block, UI_BTYPE_CHECKBOX, -- 2.30.2 From f2ece72ba0f65057a3b5f48cfcae37ae108c8a27 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Jan 2024 16:21:08 -0800 Subject: [PATCH 07/11] Dynstr -> std:string --- .../editors/space_outliner/outliner_edit.cc | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index ad83a770d14..4d0a991eed9 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2311,10 +2311,11 @@ static void wm_block_orphans_purge_button(uiBlock *block, OrphansPurgeData *purg UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); } -static void orphan_desc(bContext *C, DynStr *desc_r, bool local, bool linked, bool recursive) +static std::string orphan_desc(bContext *C, bool local, bool linked, bool recursive) { Main *bmain = CTX_data_main(C); int num_tagged[INDEX_ID_MAX] = {0}; + std::string desc; BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, local, linked, recursive, num_tagged); @@ -2322,23 +2323,22 @@ static void orphan_desc(bContext *C, DynStr *desc_r, bool local, bool linked, bo for (int i = 0; i < INDEX_ID_MAX - 2; i++) { if (num_tagged[i] != 0) { if (!is_first) { - BLI_dynstr_append(desc_r, ", "); + desc.append(", "); } else { is_first = false; } - BLI_dynstr_appendf( - desc_r, - "%d %s", - num_tagged[i], - num_tagged[i] > 1 ? + desc.append<>(std::to_string(num_tagged[i]) + " "); + desc.append(num_tagged[i] > 1 ? TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); } } - if (BLI_dynstr_get_len(desc_r) == 0) { - BLI_dynstr_append(desc_r, "Nothing"); + if (desc.empty()) { + desc = "Nothing"; } + + return desc; } static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, void *arg) @@ -2357,16 +2357,13 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo uiItemS(layout); - char text[1024]; - DynStr *dyn_str = BLI_dynstr_new(); - orphan_desc(C, dyn_str, true, false, false); - BLI_snprintf(text, 1024, "Local data: %s", BLI_dynstr_get_cstring(dyn_str)); + std::string desc = "Local data: " + orphan_desc(C, true, false, false); uiDefButBitC(block, UI_BTYPE_CHECKBOX, 1, 0, - text, + desc.c_str(), 0, 0, 0, @@ -2378,15 +2375,13 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, "Delete unused local data"); - BLI_dynstr_clear(dyn_str); - orphan_desc(C, dyn_str, false, true, false); - BLI_snprintf(text, 1024, "Linked data: %s", BLI_dynstr_get_cstring(dyn_str)); + desc = "Linked data: " + orphan_desc(C, false, true, false); uiDefButBitC(block, UI_BTYPE_CHECKBOX, 1, 0, - text, + desc.c_str(), 0, 0, 0, @@ -2398,15 +2393,11 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, "Delete unused linked data"); - BLI_dynstr_clear(dyn_str); - orphan_desc(C, dyn_str, false, false, true); - BLI_snprintf(text, 1024, "Include Indirectly Unused (Recursive)"); - uiDefButBitC(block, UI_BTYPE_CHECKBOX, 1, 0, - text, + "Include Indirectly Unused (Recursive)", 0, 0, 0, @@ -2419,8 +2410,6 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo "Recursively check for indirectly unused data, ensuring that no unused data " "remains after execution"); - BLI_dynstr_free(dyn_str); - uiItemS_ex(layout, 2.0f); /* Buttons. */ -- 2.30.2 From 05b3712d0f239e4906c348a0166aba8190380195 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Jan 2024 16:29:39 -0800 Subject: [PATCH 08/11] "Include indirect data" and some formatting changes. --- .../editors/space_outliner/outliner_edit.cc | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 4d0a991eed9..6ac30674627 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2330,8 +2330,8 @@ static std::string orphan_desc(bContext *C, bool local, bool linked, bool recurs } desc.append<>(std::to_string(num_tagged[i]) + " "); desc.append(num_tagged[i] > 1 ? - TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : - TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); + TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : + TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); } } if (desc.empty()) { @@ -2393,22 +2393,22 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo 0, "Delete unused linked data"); - uiDefButBitC(block, - UI_BTYPE_CHECKBOX, - 1, - 0, - "Include Indirectly Unused (Recursive)", - 0, - 0, - 0, - UI_UNIT_Y, - &purge_data->recursive, - 0, - 0, - 0, - 0, - "Recursively check for indirectly unused data, ensuring that no unused data " - "remains after execution"); + uiDefButBitC( + block, + UI_BTYPE_CHECKBOX, + 1, + 0, + "Include indirect data", + 0, + 0, + 0, + UI_UNIT_Y, + &purge_data->recursive, + 0, + 0, + 0, + 0, + "Recursively check for indirectly unused data, ensuring that no unused data remains"); uiItemS_ex(layout, 2.0f); -- 2.30.2 From c6011890a973583326a73a84fafa82d7e679db9e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 8 Jan 2024 12:11:52 -0800 Subject: [PATCH 09/11] Updated to incorporate changes suggested by review --- .../editors/space_outliner/CMakeLists.txt | 2 + .../editors/space_outliner/outliner_edit.cc | 39 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 26df8082a1c..8100f830dbf 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -12,6 +12,7 @@ set(INC ../../makesrna ../../sequencer ../../windowmanager + ../../../../extern/fmtlib/include # RNA_prototypes.h ${CMAKE_BINARY_DIR}/source/blender/makesrna @@ -137,6 +138,7 @@ set(LIB bf_editor_undo PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc + extern_fmtlib ) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 6ac30674627..f1469d0f6cd 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -65,6 +65,10 @@ #include "tree/tree_element_rna.hh" #include "tree/tree_iterator.hh" +#include "wm_window.hh" + +#include + using namespace blender::ed::outliner; namespace blender::ed::outliner { @@ -2322,18 +2326,17 @@ static std::string orphan_desc(bContext *C, bool local, bool linked, bool recurs bool is_first = true; for (int i = 0; i < INDEX_ID_MAX - 2; i++) { if (num_tagged[i] != 0) { - if (!is_first) { - desc.append(", "); - } - else { - is_first = false; - } - desc.append<>(std::to_string(num_tagged[i]) + " "); - desc.append(num_tagged[i] > 1 ? - TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : - TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); + desc += fmt::format( + "{}{} {}", + (is_first) ? "" : ", ", + num_tagged[i], + (num_tagged[i] > 1) ? + TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) : + TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i)))); + is_first = false; } } + if (desc.empty()) { desc = "Nothing"; } @@ -2460,16 +2463,23 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot) ot->exec = outliner_orphans_cleanup_exec; /* flags */ - ot->flag = OPTYPE_REGISTER; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/) { + int width = 800; + int height = 500; + if (wm_get_screensize(&width, &height)) { + width /= 2; + height /= 2; + } + const rcti window_rect = { /*xmin*/ 0, - /*xmax*/ 500, + /*xmax*/ width, /*ymin*/ 0, - /*ymax*/ 500, + /*ymax*/ height, }; if (WM_window_open(C, @@ -2485,8 +2495,9 @@ static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/) { SpaceOutliner *soutline = (SpaceOutliner *)CTX_wm_area(C)->spacedata.first; soutline->outlinevis = SO_ID_ORPHANS; + return OPERATOR_FINISHED; } - return OPERATOR_FINISHED; + return OPERATOR_CANCELLED; } void OUTLINER_OT_orphans_manage(wmOperatorType *ot) -- 2.30.2 From 98f5dd95b8544ed245c500f531eb8ced5746d072 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 16 Jan 2024 13:39:14 -0800 Subject: [PATCH 10/11] Changes required by review. --- source/blender/editors/space_outliner/outliner_edit.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 3678c6da6d4..b285a7497a2 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2315,7 +2315,7 @@ static void wm_block_orphans_purge_button(uiBlock *block, OrphansPurgeData *purg UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); } -static std::string orphan_desc(bContext *C, bool local, bool linked, bool recursive) +static std::string orphan_desc(const bContext *C, const bool local, bool linked, bool recursive) { Main *bmain = CTX_data_main(C); int num_tagged[INDEX_ID_MAX] = {0}; @@ -2346,7 +2346,7 @@ static std::string orphan_desc(bContext *C, bool local, bool linked, bool recurs static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, void *arg) { - OrphansPurgeData *purge_data = (OrphansPurgeData *)arg; + OrphansPurgeData *purge_data = static_cast(arg); wmOperator *op = purge_data->op; uiBlock *block = UI_block_begin(C, region, "orphans_remove_popup", UI_EMBOSS); UI_block_flag_enable( @@ -2446,7 +2446,7 @@ static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, vo static int outliner_orphans_cleanup_exec(bContext *C, wmOperator *op) { - OrphansPurgeData *purge_data = MEM_new("orphans_purge_data"); + OrphansPurgeData *purge_data = MEM_new(__func__); purge_data->op = op; UI_popup_block_invoke(C, wm_block_create_orphans_cleanup, purge_data, MEM_freeN); return OPERATOR_FINISHED; -- 2.30.2 From 56c2b3b3a3019c79074ea6fab9a4e64e6f25cbb2 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 16 Jan 2024 14:52:40 -0800 Subject: [PATCH 11/11] removing unused variable --- source/blender/editors/space_outliner/outliner_edit.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index b285a7497a2..a97488af4d0 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2347,7 +2347,6 @@ static std::string orphan_desc(const bContext *C, const bool local, bool linked, static uiBlock *wm_block_create_orphans_cleanup(bContext *C, ARegion *region, void *arg) { OrphansPurgeData *purge_data = static_cast(arg); - wmOperator *op = purge_data->op; uiBlock *block = UI_block_begin(C, region, "orphans_remove_popup", UI_EMBOSS); UI_block_flag_enable( block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT); -- 2.30.2