diff options
author | Julian Eisel <julian@blender.org> | 2021-02-06 21:25:11 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-02-06 21:27:55 +0300 |
commit | 699b2d98553f2b0c4bb74dc263d3251600fadd25 (patch) | |
tree | fe0e9bf1ed261a0f2342f8f47d8227d2e22ad124 /source | |
parent | ef29ebb31bd4bad47f55f45d6b4a2ab40fe09caf (diff) |
Code quality: Port recently added utility file to C++
It seems generally preferred to have new files be created with C++.
The only reason I didn't do that when I initially created the files is that I
was unsure about some C-API aspect.
Also use nullptr instead of NULL.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/util/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util_ops.cc (renamed from source/blender/editors/util/ed_util_ops.c) | 28 |
2 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 0aab3810254..38655b8490e 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -39,7 +39,7 @@ set(SRC ed_transverts.c ed_util.c ed_util_imbuf.c - ed_util_ops.c + ed_util_ops.cc gizmo_utils.c numinput.c select_utils.c diff --git a/source/blender/editors/util/ed_util_ops.c b/source/blender/editors/util/ed_util_ops.cc index bb531b11b12..cb7ff9f3a63 100644 --- a/source/blender/editors/util/ed_util_ops.c +++ b/source/blender/editors/util/ed_util_ops.cc @@ -22,6 +22,9 @@ #include <string.h> +#include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" + #include "BLI_fileops.h" #include "BLI_utildefines.h" @@ -33,9 +36,6 @@ #include "BLT_translation.h" -#include "DNA_space_types.h" -#include "DNA_windowmanager_types.h" - #include "ED_render.h" #include "ED_undo.h" #include "ED_util.h" @@ -56,7 +56,7 @@ static bool lib_id_preview_editing_poll(bContext *C) const PointerRNA idptr = CTX_data_pointer_get(C, "id"); BLI_assert(!idptr.data || RNA_struct_is_ID(idptr.type)); - const ID *id = idptr.data; + const ID *id = (ID *)idptr.data; if (!id) { return false; } @@ -88,11 +88,11 @@ static int lib_id_load_custom_preview_exec(bContext *C, wmOperator *op) } PointerRNA idptr = CTX_data_pointer_get(C, "id"); - ID *id = idptr.data; + ID *id = (ID *)idptr.data; BKE_previewimg_id_custom_set(id, path); - WM_event_add_notifier(C, NC_ASSET, NULL); + WM_event_add_notifier(C, NC_ASSET, nullptr); return OPERATOR_FINISHED; } @@ -123,7 +123,7 @@ static void ED_OT_lib_id_load_custom_preview(wmOperatorType *ot) static int lib_id_generate_preview_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA idptr = CTX_data_pointer_get(C, "id"); - ID *id = idptr.data; + ID *id = (ID *)idptr.data; ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -131,9 +131,9 @@ static int lib_id_generate_preview_exec(bContext *C, wmOperator *UNUSED(op)) if (preview) { BKE_previewimg_clear(preview); } - UI_icon_render_id(C, NULL, id, ICON_SIZE_PREVIEW, true); + UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true); - WM_event_add_notifier(C, NC_ASSET, NULL); + WM_event_add_notifier(C, NC_ASSET, nullptr); return OPERATOR_FINISHED; } @@ -169,15 +169,15 @@ static int lib_id_fake_user_toggle_exec(bContext *C, wmOperator *op) idptr = RNA_property_pointer_get(&pprop.ptr, pprop.prop); } - if ((pprop.prop == NULL) || RNA_pointer_is_null(&idptr) || !RNA_struct_is_ID(idptr.type)) { + if ((pprop.prop == nullptr) || RNA_pointer_is_null(&idptr) || !RNA_struct_is_ID(idptr.type)) { BKE_report( op->reports, RPT_ERROR, "Incorrect context for running data-block fake user toggling"); return OPERATOR_CANCELLED; } - ID *id = idptr.data; + ID *id = (ID *)idptr.data; - if ((id->lib != NULL) || (ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) { + if ((id->lib != nullptr) || (ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) { BKE_report(op->reports, RPT_ERROR, "Data-block type does not support fake user"); return OPERATOR_CANCELLED; } @@ -217,14 +217,14 @@ static int lib_id_unlink_exec(bContext *C, wmOperator *op) idptr = RNA_property_pointer_get(&pprop.ptr, pprop.prop); } - if ((pprop.prop == NULL) || RNA_pointer_is_null(&idptr) || !RNA_struct_is_ID(idptr.type)) { + if ((pprop.prop == nullptr) || RNA_pointer_is_null(&idptr) || !RNA_struct_is_ID(idptr.type)) { BKE_report( op->reports, RPT_ERROR, "Incorrect context for running data-block fake user toggling"); return OPERATOR_CANCELLED; } memset(&idptr, 0, sizeof(idptr)); - RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr, NULL); + RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr, nullptr); RNA_property_update(C, &pprop.ptr, pprop.prop); return OPERATOR_FINISHED; |