[Bf-blender-cvs] [1a50f814e6a] master: Cleanup: Remove unused variable, use switch, and C++ casting.
Bastien Montagne
noreply at git.blender.org
Mon Jan 30 15:41:06 CET 2023
Commit: 1a50f814e6aad72bb8da7e571cee49ac4022ed84
Author: Bastien Montagne
Date: Mon Jan 30 15:40:29 2023 +0100
Branches: master
https://developer.blender.org/rB1a50f814e6aad72bb8da7e571cee49ac4022ed84
Cleanup: Remove unused variable, use switch, and C++ casting.
===================================================================
M source/blender/blenloader/intern/readfile.cc
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index 2e1619b4c9f..c440dbf8c7a 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -2299,11 +2299,11 @@ static bool lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
{
IDNameLib_Map *id_map = static_cast<IDNameLib_Map *>(arg_pt);
- lib_link_seq_clipboard_pt_restore((ID *)seq->scene, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->clip, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->mask, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->sound, id_map);
+ lib_link_seq_clipboard_pt_restore(reinterpret_cast<ID *>(seq->scene), id_map);
+ lib_link_seq_clipboard_pt_restore(reinterpret_cast<ID *>(seq->scene_camera), id_map);
+ lib_link_seq_clipboard_pt_restore(reinterpret_cast<ID *>(seq->clip), id_map);
+ lib_link_seq_clipboard_pt_restore(reinterpret_cast<ID *>(seq->mask), id_map);
+ lib_link_seq_clipboard_pt_restore(reinterpret_cast<ID *>(seq->sound), id_map);
return true;
}
@@ -2325,7 +2325,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data)
/* We probably need to add more cases here (hint: nodetrees),
* but will wait for changes from D5559 to get in first. */
if (GS((*id_pointer)->name) == ID_GR) {
- Collection *collection = (Collection *)*id_pointer;
+ Collection *collection = reinterpret_cast<Collection *>(*id_pointer);
if (collection->flag & COLLECTION_IS_MASTER) {
/* We should never reach that point anymore, since master collection private ID should be
* properly tagged with IDWALK_CB_EMBEDDED. */
@@ -2357,7 +2357,7 @@ static void lib_link_main_data_restore(IDNameLib_Map *id_map, Main *newmain)
static void lib_link_wm_xr_data_restore(IDNameLib_Map *id_map, wmXrData *xr_data)
{
xr_data->session_settings.base_pose_object = static_cast<Object *>(restore_pointer_by_name(
- id_map, (ID *)xr_data->session_settings.base_pose_object, USER_REAL));
+ id_map, reinterpret_cast<ID *>(xr_data->session_settings.base_pose_object), USER_REAL));
}
static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, ViewLayer *view_layer)
@@ -2367,7 +2367,7 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
+ View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->camera == nullptr || v3d->scenelock) {
v3d->camera = scene->camera;
@@ -2416,7 +2416,7 @@ static void lib_link_restore_viewer_path(IDNameLib_Map *id_map, ViewerPath *view
if (elem->type == VIEWER_PATH_ELEM_TYPE_ID) {
IDViewerPathElem *typed_elem = reinterpret_cast<IDViewerPathElem *>(elem);
typed_elem->id = static_cast<ID *>(
- restore_pointer_by_name(id_map, (ID *)typed_elem->id, USER_IGNORE));
+ restore_pointer_by_name(id_map, typed_elem->id, USER_IGNORE));
}
}
}
@@ -2431,225 +2431,253 @@ static void lib_link_workspace_layout_restore(IDNameLib_Map *id_map,
{
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
+ switch (static_cast<eSpace_Type>(sl->spacetype)) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = reinterpret_cast<View3D *>(sl);
- v3d->camera = static_cast<Object *>(
- restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL));
- v3d->ob_center = static_cast<Object *>(
- restore_pointer_by_name(id_map, (ID *)v3d->ob_center, USER_REAL));
+ v3d->camera = static_cast<Object *>(
+ restore_pointer_by_name(id_map, reinterpret_cast<ID *>(v3d->camera), USER_REAL));
+ v3d->ob_center = static_cast<Object *>(restore_pointer_by_name(
+ id_map, reinterpret_cast<ID *>(v3d->ob_center), USER_REAL));
- lib_link_restore_viewer_path(id_map, &v3d->viewer_path);
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- bDopeSheet *ads = sipo->ads;
+ lib_link_restore_viewer_path(id_map, &v3d->viewer_path);
+ break;
+ }
+ case SPACE_GRAPH: {
+ SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(sl);
+ bDopeSheet *ads = sipo->ads;
- if (ads) {
- ads->source = static_cast<ID *>(
- restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL));
+ if (ads) {
+ ads->source = static_cast<ID *>(
+ restore_pointer_by_name(id_map, reinterpret_cast<ID *>(ads->source), USER_REAL));
- if (ads->filter_grp) {
- ads->filter_grp = static_cast<Collection *>(
- restore_pointer_by_name(id_map, (ID *)ads->filter_grp, USER_IGNORE));
+ if (ads->filter_grp) {
+ ads->filter_grp = static_cast<Collection *>(restore_pointer_by_name(
+ id_map, reinterpret_cast<ID *>(ads->filter_grp), USER_IGNORE));
+ }
}
+
+ /* force recalc of list of channels (i.e. includes calculating F-Curve colors)
+ * thus preventing the "black curves" problem post-undo
+ */
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
+ break;
}
+ case SPACE_PROPERTIES: {
+ SpaceProperties *sbuts = reinterpret_cast<SpaceProperties *>(sl);
+ sbuts->pinid = static_cast<ID *>(
+ restore_pointer_by_name(id_map, sbuts->pinid, USER_IGNORE));
+ if (sbuts->pinid == nullptr) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
- /* force recalc of list of channels (i.e. includes calculating F-Curve colors)
- * thus preventing the "black curves" problem post-undo
- */
- sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- sbuts->pinid = static_cast<ID *>(
- restore_pointer_by_name(id_map, sbuts->pinid, USER_IGNORE));
- if (sbuts->pinid == nullptr) {
- sbuts->flag &= ~SB_PIN_CONTEXT;
+ /* TODO: restore path pointers: T40046
+ * (complicated because this contains data pointers too, not just ID). */
+ MEM_SAFE_FREE(sbuts->path);
+ break;
+ }
+ case SPACE_FILE: {
+ SpaceFile *sfile = reinterpret_cast<SpaceFile *>(sl);
+ sfile->op = nullptr;
+ sfile->tags = FILE_TAG_REBUILD_MAIN_FILES;
+ break;
}
+ case SPACE_ACTION: {
+ SpaceAction *saction = reinterpret_cast<SpaceAction *>(sl);
- /* TODO: restore path pointers: T40046
- * (complicated because this contains data pointers too, not just ID). */
- MEM_SAFE_FREE(sbuts->path);
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
- sfile->op = nullptr;
- sfile->tags = FILE_TAG_REBUILD_MAIN_FILES;
- }
- else if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
+ saction->action = static_cast<bAction *>(restore_pointer_by_name(
+ id_map, reinterpret_cast<ID *>(saction->action), USER_REAL));
+ saction->ads.source = static_cast<ID *>(restore_pointer_by_name(
+ id_map, reinterpret_cast<ID *>(saction->ads.source), USER_REAL));
- saction->action = static_cast<bAction *>(
- restore_pointer_by_name(id_map, (ID *)saction->action, USER_REAL));
- saction->ads.source = static_cast<ID *>(
- restore_pointer_by_name(id_map, (ID *)saction->ads.source, USER_REAL));
+ if (saction->ads.filter_grp) {
+ saction->ads.filter_grp = static_cast<Collection *>(restore_pointer_by_name(
+ id_map, reinterpret_cast<ID *>(saction->ads.filter_grp), USER_IGNORE));
+ }
- if (saction->ads.filter_grp) {
- saction->ads.filter_grp = static_cast<Collection *>(
- restore_pointer_by_name(id_map, (ID *)saction->ads.filter_grp, USER_IGNORE));
+ /* force recalc of list of channels, potentially updating the active action
+ * while we're at it (as it can only be updated that way) T28962.
+ */
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
+ break;
}
+ case SPACE_IMAGE: {
+ SpaceImage *sima = reinterpret_cast<SpaceImage *>(sl);
- /* force recalc of list of channels, potentially updating the active action
- * while we're at it (as it can only be updated that way) T28962.
- */
- saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->image = static_cast<Image *>(
- restore_pointer_by_name(id_map, (ID *)sima->image, USER_REAL));
+ sima->image = static_cast<Image *>(
+ restore_pointer_by_name(id_map, reinterpret_cast<ID *>(sima->image), USER_REAL));
- /* this will be freed, not worth attempting to find same scene,
- * since it gets initialized later */
- sima->iuser.scene = nullptr;
+ /* this will be freed, not worth attempting to find same scene,
+ * since it gets initialized later */
+ sima->iuser.scene = nullptr;
#if 0
- /* Those are allocated and freed by space code, no need to handle them here. */
- MEM_SAF
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list