[Bf-blender-cvs] [c4752013786] blender-projects-basics: Use operator poll instead of cancelling; Minor cleanup

Julian Eisel noreply at git.blender.org
Tue Oct 18 18:28:24 CEST 2022


Commit: c47520137867b67a936dc78053742dc1ae759d3e
Author: Julian Eisel
Date:   Tue Oct 18 17:32:10 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rBc47520137867b67a936dc78053742dc1ae759d3e

Use operator poll instead of cancelling; Minor cleanup

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

M	release/scripts/startup/bl_ui/utils.py
M	source/blender/blenkernel/BKE_blender_project.hh
M	source/blender/editors/project/project_ops.cc

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

diff --git a/release/scripts/startup/bl_ui/utils.py b/release/scripts/startup/bl_ui/utils.py
index 6c51de2395a..346995322bc 100644
--- a/release/scripts/startup/bl_ui/utils.py
+++ b/release/scripts/startup/bl_ui/utils.py
@@ -73,4 +73,3 @@ class CenterAlignMixIn:
 
         if is_wide:
             row.label()  # Needed so col above is centered.
-
diff --git a/source/blender/blenkernel/BKE_blender_project.hh b/source/blender/blenkernel/BKE_blender_project.hh
index bbf80303305..185860674c6 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -170,7 +170,7 @@ class ProjectSettings {
    * Both Unix and Windows style slashes are allowed. Path is expected to be normalized.
    *
    * \return True on success. If the .blender_project directory doesn't exist, that's treated
-   * as failure.
+   *         as failure.
    */
   auto save_to_disk(StringRef project_path) -> bool;
 
diff --git a/source/blender/editors/project/project_ops.cc b/source/blender/editors/project/project_ops.cc
index c0ae738f2f0..797b4fd3f56 100644
--- a/source/blender/editors/project/project_ops.cc
+++ b/source/blender/editors/project/project_ops.cc
@@ -180,12 +180,6 @@ static void PROJECT_OT_delete_setup(wmOperatorType *ot)
 static int custom_asset_library_add_exec(bContext *UNUSED(C), wmOperator *op)
 {
   BlenderProject *project = CTX_wm_project();
-  if (!project) {
-    BKE_report(op->reports,
-               RPT_ERROR,
-               "Couldn't create project asset library, there is no active project");
-    return OPERATOR_CANCELLED;
-  }
 
   char path[FILE_MAXDIR];
   char dirname[FILE_MAXFILE];
@@ -230,6 +224,7 @@ static void PROJECT_OT_custom_asset_library_add(wmOperatorType *ot)
 
   ot->exec = custom_asset_library_add_exec;
   ot->invoke = custom_asset_library_add_invoke;
+  ot->poll = has_active_project_poll;
 
   ot->flag = OPTYPE_INTERNAL;
 
@@ -253,13 +248,6 @@ static int custom_asset_library_remove_exec(bContext *UNUSED(C), wmOperator *op)
   const int index = RNA_int_get(op->ptr, "index");
 
   BlenderProject *project = CTX_wm_project();
-  if (!project) {
-    BKE_report(op->reports,
-               RPT_ERROR,
-               "Couldn't remove project asset library, there is no active project");
-    return OPERATOR_CANCELLED;
-  }
-
   ListBase *asset_libraries = BKE_project_custom_asset_libraries_get(project);
   CustomAssetLibraryDefinition *library = BKE_asset_library_custom_find_from_index(asset_libraries,
                                                                                    index);
@@ -282,6 +270,7 @@ static void PROJECT_OT_custom_asset_library_remove(wmOperatorType *ot)
       "anymore";
 
   ot->exec = custom_asset_library_remove_exec;
+  ot->poll = has_active_project_poll;
 
   ot->flag = OPTYPE_INTERNAL;



More information about the Bf-blender-cvs mailing list