[Bf-blender-cvs] [08228956d9f] temp-ui-cpp: Cleanup: Move outliner_tools.c to C++

Hans Goudey noreply at git.blender.org
Sat Nov 20 23:00:50 CET 2021


Commit: 08228956d9f0940512148f1c510a1020d6ec49a5
Author: Hans Goudey
Date:   Sat Nov 20 17:00:41 2021 -0500
Branches: temp-ui-cpp
https://developer.blender.org/rB08228956d9f0940512148f1c510a1020d6ec49a5

Cleanup: Move outliner_tools.c to C++

===================================================================

M	source/blender/editors/space_outliner/CMakeLists.txt
R089	source/blender/editors/space_outliner/outliner_tools.c	source/blender/editors/space_outliner/outliner_tools.cc

===================================================================

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index c31239f0e9c..e0e3c24e895 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -42,7 +42,7 @@ set(SRC
   outliner_ops.c
   outliner_select.c
   outliner_sync.c
-  outliner_tools.c
+  outliner_tools.cc
   outliner_tree.c
   outliner_utils.c
   space_outliner.c
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.cc
similarity index 89%
rename from source/blender/editors/space_outliner/outliner_tools.c
rename to source/blender/editors/space_outliner/outliner_tools.cc
index ae2b1870884..8acf877b81f 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -208,7 +208,7 @@ static bool outliner_operation_tree_element_poll(bContext *C)
   }
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
   TreeElement *te = get_target_element(space_outliner);
-  if (te == NULL) {
+  if (te == nullptr) {
     return false;
   }
 
@@ -223,8 +223,8 @@ static void unlink_action_fn(bContext *C,
                              TreeStoreElem *UNUSED(tselem),
                              void *UNUSED(user_data))
 {
-  /* just set action to NULL */
-  BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL);
+  /* just set action to nullptr */
+  BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, nullptr);
 }
 
 static void unlink_material_fn(bContext *UNUSED(C),
@@ -235,7 +235,7 @@ static void unlink_material_fn(bContext *UNUSED(C),
                                TreeStoreElem *UNUSED(tselem),
                                void *UNUSED(user_data))
 {
-  Material **matar = NULL;
+  Material **matar = nullptr;
   int a, totcol = 0;
 
   if (GS(tsep->id->name) == ID_OB) {
@@ -277,11 +277,11 @@ static void unlink_material_fn(bContext *UNUSED(C),
     BLI_assert(0);
   }
 
-  if (LIKELY(matar != NULL)) {
+  if (LIKELY(matar != nullptr)) {
     for (a = 0; a < totcol; a++) {
       if (a == te->index && matar[a]) {
         id_us_min(&matar[a]->id);
-        matar[a] = NULL;
+        matar[a] = nullptr;
       }
     }
   }
@@ -295,7 +295,7 @@ static void unlink_texture_fn(bContext *UNUSED(C),
                               TreeStoreElem *UNUSED(tselem),
                               void *UNUSED(user_data))
 {
-  MTex **mtex = NULL;
+  MTex **mtex = nullptr;
   int a;
 
   if (GS(tsep->id->name) == ID_LS) {
@@ -310,7 +310,7 @@ static void unlink_texture_fn(bContext *UNUSED(C),
     if (a == te->index && mtex[a]) {
       if (mtex[a]->tex) {
         id_us_min(&mtex[a]->tex->id);
-        mtex[a]->tex = NULL;
+        mtex[a]->tex = nullptr;
       }
     }
   }
@@ -330,7 +330,7 @@ static void unlink_collection_fn(bContext *C,
   if (tsep) {
     if (GS(tsep->id->name) == ID_OB) {
       Object *ob = (Object *)tsep->id;
-      ob->instance_collection = NULL;
+      ob->instance_collection = nullptr;
       DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
       DEG_relations_tag_update(bmain);
     }
@@ -369,7 +369,7 @@ static void unlink_object_fn(bContext *C,
       TreeElement *te_parent = te->parent;
       while (tsep && GS(tsep->id->name) == ID_OB) {
         te_parent = te_parent->parent;
-        tsep = te_parent ? TREESTORE(te_parent) : NULL;
+        tsep = te_parent ? TREESTORE(te_parent) : nullptr;
       }
     }
 
@@ -404,7 +404,7 @@ static void unlink_world_fn(bContext *UNUSED(C),
 
   /* need to use parent scene not just scene, otherwise may end up getting wrong one */
   id_us_min(&wo->id);
-  parscene->world = NULL;
+  parscene->world = nullptr;
 }
 
 static void outliner_do_libdata_operation(bContext *C,
@@ -420,7 +420,7 @@ static void outliner_do_libdata_operation(bContext *C,
     if (tselem->flag & TSE_SELECTED) {
       if (((tselem->type == TSE_SOME_ID) && (te->idcode != 0)) ||
           tselem->type == TSE_LAYER_COLLECTION) {
-        TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
+        TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : nullptr;
         operation_fn(C, reports, scene, te, tsep, tselem, user_data);
       }
     }
@@ -437,13 +437,13 @@ static void outliner_do_libdata_operation(bContext *C,
 /** \name Scene Menu Operator
  * \{ */
 
-typedef enum eOutliner_PropSceneOps {
+enum eOutliner_PropSceneOps {
   OL_SCENE_OP_DELETE = 1,
-} eOutliner_PropSceneOps;
+};
 
 static const EnumPropertyItem prop_scene_op_types[] = {
     {OL_SCENE_OP_DELETE, "DELETE", ICON_X, "Delete", ""},
-    {0, NULL, 0, NULL, NULL},
+    {0, nullptr, 0, nullptr, nullptr},
 };
 
 static bool outliner_do_scene_operation(
@@ -488,7 +488,7 @@ static bool scene_fn(bContext *C,
 static int outliner_scene_operation_exec(bContext *C, wmOperator *op)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  const eOutliner_PropSceneOps event = RNA_enum_get(op->ptr, "type");
+  const eOutliner_PropSceneOps event = (eOutliner_PropSceneOps)RNA_enum_get(op->ptr, "type");
 
   if (outliner_do_scene_operation(C, event, &space_outliner->tree, scene_fn) == false) {
     return OPERATOR_CANCELLED;
@@ -534,10 +534,10 @@ void OUTLINER_OT_scene_operation(wmOperatorType *ot)
  * the merged select popup menu. The sub-tree of the parent is searched and
  * the child is needed to only show elements of the same type in the popup.
  */
-typedef struct MergedSearchData {
+struct MergedSearchData {
   TreeElement *parent_element;
   TreeElement *select_element;
-} MergedSearchData;
+};
 
 static void merged_element_search_fn_recursive(
     const ListBase *tree, short tselem_type, short type, const char *str, uiSearchItems *items)
@@ -615,13 +615,13 @@ static uiBlock *merged_element_search_menu(bContext *C, ARegion *region, void *d
   but = uiDefSearchBut(
       block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, menu_width, UI_UNIT_Y, 0, 0, "");
   UI_but_func_search_set(but,
-                         NULL,
+                         nullptr,
                          merged_element_search_update_fn,
                          data,
                          false,
-                         NULL,
+                         nullptr,
                          merged_element_search_exec_fn,
-                         NULL);
+                         nullptr);
   UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
 
   /* Fake button to hold space for search items */
@@ -633,15 +633,16 @@ static uiBlock *merged_element_search_menu(bContext *C, ARegion *region, void *d
            10 - UI_searchbox_size_y(),
            menu_width,
            UI_searchbox_size_y(),
-           NULL,
+           nullptr,
            0,
            0,
            0,
            0,
-           NULL);
+           nullptr);
 
   /* Center the menu on the cursor */
-  UI_block_bounds_set_popup(block, 6, (const int[2]){-(menu_width / 2), 0});
+  const int offset[2] = {-(menu_width / 2), 0};
+  UI_block_bounds_set_popup(block, 6, offset);
 
   return block;
 }
@@ -650,7 +651,8 @@ void merged_element_search_menu_invoke(bContext *C,
                                        TreeElement *parent_te,
                                        TreeElement *activate_te)
 {
-  MergedSearchData *select_data = MEM_callocN(sizeof(MergedSearchData), "merge_search_data");
+  MergedSearchData *select_data = (MergedSearchData *)MEM_callocN(sizeof(MergedSearchData),
+                                                                  __func__);
   select_data->parent_element = parent_te;
   select_data->select_element = activate_te;
 
@@ -773,7 +775,7 @@ static void object_proxy_to_override_convert_fn(bContext *C,
   Object *ob_proxy = (Object *)id_proxy;
   Scene *scene = CTX_data_scene(C);
 
-  if (ob_proxy->proxy == NULL) {
+  if (ob_proxy->proxy == nullptr) {
     return;
   }
 
@@ -788,17 +790,17 @@ static void object_proxy_to_override_convert_fn(bContext *C,
   }
 
   DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE);
-  WM_event_add_notifier(C, NC_WINDOW, NULL);
+  WM_event_add_notifier(C, NC_WINDOW, nullptr);
 }
 
-typedef struct OutlinerLibOverrideData {
+struct OutlinerLibOverrideData {
   bool do_hierarchy;
   /**
    * For resync operation, force keeping newly created override IDs (or original linked IDs)
    * instead of re-applying relevant existing ID pointer property override operations. Helps
    * solving broken overrides while not losing *all* of your overrides. */
   bool do_resync_hierarchy_enforce;
-} OutlinerLibOverrideData;
+};
 
 static void id_override_library_create_fn(bContext *C,
                                           ReportList *reports,
@@ -810,13 +812,13 @@ static void id_override_library_create_fn(bContext *C,
 {
   BLI_assert(TSE_IS_REAL_ID(tselem));
   ID *id_root = tselem->id;
-  OutlinerLibOverrideData *data = user_data;
+  OutlinerLibOverrideData *data = (OutlinerLibOverrideData *)user_data;
   const bool do_hierarchy = data->do_hierarchy;
   bool success = false;
 
-  ID *id_reference = NULL;
+  ID *id_reference = nullptr;
   bool is_override_instancing_object = false;
-  if (tsep != NULL && tsep->type == TSE_SOME_ID && tsep->id != NULL &&
+  if (tsep != nullptr && tsep->type == TSE_SOME_ID && tsep->id != nullptr &&
       GS(tsep->id->name) == ID_OB) {
     Object *ob = (Object *)tsep->id;
     if (ob->type == OB_EMPTY && &ob->instance_collection->id == id_root) {
@@ -847,7 +849,7 @@ static void id_override_library_create_fn(bContext *C,
 
     if (do_hierarchy) {
       /* Tag all linked parents in tree hierarchy to be also overridden. */
-      while ((te = te->parent) != NULL) {
+      while ((te = te->parent) != nullptr) {
         if (!TSE_IS_REAL_ID(te->store_elem)) {
           continue;
         }
@@ -869,10 +871,10 @@ static void id_override_library_create_fn(bContext *C,
       }
 
       success = BKE_lib_override_library_create(
-          bmain, CTX_data_scene(C), CTX_data_view_layer(C), id_root, id_reference, NULL);
+          bmain, CTX_data_scene(C), CTX_data_view_layer(C), id_root, id_reference, nullptr);
     }
     else if (ID_IS_OVERRIDABLE_LIBRARY(id_root)) 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list