Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_ops.c')
-rw-r--r--source/blender/editors/interface/interface_ops.c85
1 files changed, 33 insertions, 52 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 4bbccec7f9d..316a4d34881 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -283,14 +283,24 @@ static bool copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb, bo
return true;
}
-static int copy_to_selected_button_poll(bContext *C)
+/**
+ * called from both exec & poll
+ *
+ * \note: normally we wouldn't call a loop from within a poll function,
+ * However this is a special case, and for regular poll calls, getting
+ * the context from the button will fail early.
+ */
+static bool copy_to_selected_button(bContext *C, bool all, bool poll)
{
PointerRNA ptr, lptr, idptr;
PropertyRNA *prop, *lprop;
- int index, success = 0;
+ bool success = false;
+ int index;
+ /* try to reset the nominated setting to its default value */
uiContextActiveProperty(C, &ptr, &prop, &index);
+ /* if there is a valid property that is editable... */
if (ptr.data && prop) {
char *path = NULL;
bool use_path;
@@ -314,8 +324,18 @@ static int copy_to_selected_button_poll(bContext *C)
}
if (lprop == prop) {
- if (RNA_property_editable(&lptr, prop))
- success = 1;
+ if (RNA_property_editable(&lptr, lprop)) {
+ if (poll) {
+ success = true;
+ break;
+ }
+ else {
+ if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+ RNA_property_update(C, &lptr, prop);
+ success = true;
+ }
+ }
+ }
}
}
}
@@ -330,58 +350,19 @@ static int copy_to_selected_button_poll(bContext *C)
return success;
}
-static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
+static int copy_to_selected_button_poll(bContext *C)
{
- PointerRNA ptr, lptr, idptr;
- PropertyRNA *prop, *lprop;
- bool success = false;
- int index;
- const bool all = RNA_boolean_get(op->ptr, "all");
-
- /* try to reset the nominated setting to its default value */
- uiContextActiveProperty(C, &ptr, &prop, &index);
-
- /* if there is a valid property that is editable... */
- if (ptr.data && prop) {
- char *path = NULL;
- bool use_path;
- CollectionPointerLink *link;
- ListBase lb;
-
- if (!copy_to_selected_list(C, &ptr, &lb, &use_path))
- return OPERATOR_CANCELLED;
+ return copy_to_selected_button(C, false, true);
+}
- if (!use_path || (path = RNA_path_from_ID_to_property(&ptr, prop))) {
- for (link = lb.first; link; link = link->next) {
- if (link->ptr.data != ptr.data) {
- if (use_path) {
- lprop = NULL;
- RNA_id_pointer_create(link->ptr.id.data, &idptr);
- RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
- }
- else {
- lptr = link->ptr;
- lprop = prop;
- }
+static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
+{
+ bool success;
- if (lprop == prop) {
- if (RNA_property_editable(&lptr, lprop)) {
- if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
- RNA_property_update(C, &lptr, prop);
- success = true;
- }
- }
- }
- }
- }
+ const bool all = RNA_boolean_get(op->ptr, "all");
- if (path)
- MEM_freeN(path);
- }
+ success = copy_to_selected_button(C, all, false);
- BLI_freelistN(&lb);
- }
-
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -678,7 +659,7 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch
/* Now try without the second iso code part (_ES in es_ES). */
{
- char *tc = NULL;
+ const char *tc = NULL;
size_t szt = 0;
tstr[0] = '\0';