Fix #129542: GPv3: Layers and Groups don't generate callback to message bus
Layers and layer groups did not generate message bus callbacks. This was a regression from 4.2. The fix adds `WM_msg_publish_rna_prop` to (some) places where the layers/groups change or the active one changes. Also resolves #129539. Note: This does not cover every possible scenario and only fixes the regressions from 4.2. The message bus is still very unreliable when it comes to detecting changes of properties. Pull Request: https://projects.blender.org/blender/blender/pulls/130039
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include "ANIM_fcurve.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_message.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
@@ -4431,6 +4432,8 @@ static int click_select_channel_grease_pencil_layer(bContext *C,
|
||||
/* Active channel is not changed during range select. */
|
||||
if (layer->is_selected() && (selectmode != SELECT_EXTEND_RANGE)) {
|
||||
grease_pencil->set_active_layer(layer);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil->id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_message.hh"
|
||||
|
||||
namespace blender::ed::greasepencil {
|
||||
|
||||
@@ -94,6 +95,8 @@ static int grease_pencil_layer_add_exec(bContext *C, wmOperator *op)
|
||||
op->ptr, "new_layer_name", nullptr, 0, &new_layer_name_length);
|
||||
BLI_SCOPED_DEFER([&] { MEM_SAFE_FREE(new_layer_name); });
|
||||
Layer &new_layer = grease_pencil.add_layer(new_layer_name);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
|
||||
if (grease_pencil.has_active_layer()) {
|
||||
grease_pencil.move_node_after(new_layer.as_node(),
|
||||
@@ -101,9 +104,17 @@ static int grease_pencil_layer_add_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else if (grease_pencil.has_active_group()) {
|
||||
grease_pencil.move_node_into(new_layer.as_node(), *grease_pencil.get_active_group());
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
}
|
||||
|
||||
grease_pencil.set_active_layer(&new_layer);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
|
||||
grease_pencil.insert_frame(new_layer, scene->r.cfra);
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
@@ -152,6 +163,11 @@ static int grease_pencil_layer_remove_exec(bContext *C, wmOperator * /*op*/)
|
||||
|
||||
grease_pencil.remove_layer(*grease_pencil.get_active_layer());
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, &grease_pencil);
|
||||
|
||||
@@ -222,6 +238,11 @@ static int grease_pencil_layer_reorder_exec(bContext *C, wmOperator *op)
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layer_groups);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -300,6 +321,9 @@ static int grease_pencil_layer_move_exec(bContext *C, wmOperator *op)
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -330,8 +354,19 @@ static int grease_pencil_layer_active_exec(bContext *C, wmOperator *op)
|
||||
if (grease_pencil.is_layer_active(&layer)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (grease_pencil.has_active_group()) {
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
}
|
||||
grease_pencil.set_active_layer(&layer);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, &grease_pencil);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -372,15 +407,22 @@ static int grease_pencil_layer_group_add_exec(bContext *C, wmOperator *op)
|
||||
}();
|
||||
|
||||
LayerGroup &new_group = grease_pencil.add_layer_group(parent_group, new_layer_group_name);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layer_groups);
|
||||
|
||||
if (grease_pencil.has_active_layer()) {
|
||||
grease_pencil.move_node_after(new_group.as_node(),
|
||||
grease_pencil.get_active_layer()->as_node());
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(new_layer_group_name);
|
||||
grease_pencil.set_active_node(&new_group.as_node());
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3LayerGroup, active);
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
|
||||
@@ -423,6 +465,11 @@ static int grease_pencil_layer_group_remove_exec(bContext *C, wmOperator *op)
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, &grease_pencil);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3LayerGroup, active);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layer_groups);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -647,6 +694,9 @@ static int grease_pencil_layer_duplicate_exec(bContext *C, wmOperator *op)
|
||||
Layer &active_layer = *grease_pencil.get_active_layer();
|
||||
Layer &new_layer = grease_pencil.duplicate_layer(active_layer);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
|
||||
/* Clear source keyframes and recreate them with duplicated drawings. */
|
||||
new_layer.frames_for_write().clear();
|
||||
for (auto [frame_number, frame] : active_layer.frames().items()) {
|
||||
@@ -668,6 +718,10 @@ static int grease_pencil_layer_duplicate_exec(bContext *C, wmOperator *op)
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, nullptr);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -765,6 +819,11 @@ static int grease_pencil_merge_layer_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Remove the active group. */
|
||||
grease_pencil.remove_group(active_group, true);
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
|
||||
/* Rename the first node so that the merged layer will have the name of the group. */
|
||||
grease_pencil.rename_node(
|
||||
@@ -797,11 +856,17 @@ static int grease_pencil_merge_layer_exec(bContext *C, wmOperator *op)
|
||||
grease_pencil, src_layer_indices_by_dst_layer, *merged_grease_pencil);
|
||||
BKE_grease_pencil_nomain_to_grease_pencil(merged_grease_pencil, &grease_pencil);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
|
||||
/* Try to set the active (merged) layer. */
|
||||
TreeNode *node = grease_pencil.find_node_by_name(merged_layer_name);
|
||||
if (node && node->is_layer()) {
|
||||
Layer &layer = node->as_layer();
|
||||
grease_pencil.set_active_layer(&layer);
|
||||
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ED_undo.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_message.hh"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -137,6 +138,22 @@ class LayerNodeDropTarget : public TreeViewItemDropTarget {
|
||||
}
|
||||
}
|
||||
|
||||
if (drag_node.is_layer()) {
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layers);
|
||||
}
|
||||
else if (drag_node.is_group()) {
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3, layer_groups);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
|
||||
return true;
|
||||
@@ -221,6 +238,14 @@ class LayerViewItem : public AbstractTreeViewItem {
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(&layers_ptr, "active");
|
||||
|
||||
if (grease_pencil_.has_active_group()) {
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(&C),
|
||||
&grease_pencil_.id,
|
||||
&grease_pencil_,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
}
|
||||
|
||||
RNA_property_pointer_set(&layers_ptr, prop, value_ptr, nullptr);
|
||||
RNA_property_update(&C, &layers_ptr, prop);
|
||||
|
||||
@@ -340,6 +365,14 @@ class LayerGroupViewItem : public AbstractTreeViewItem {
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(&grease_pencil_ptr, "active");
|
||||
|
||||
if (grease_pencil_.has_active_layer()) {
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(&C),
|
||||
&grease_pencil_.id,
|
||||
&grease_pencil_,
|
||||
GreasePencilv3Layers,
|
||||
active);
|
||||
}
|
||||
|
||||
RNA_property_pointer_set(&grease_pencil_ptr, prop, value_ptr, nullptr);
|
||||
RNA_property_update(&C, &grease_pencil_ptr, prop);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "SEQ_sequencer.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_message.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "UI_interface.hh"
|
||||
@@ -498,7 +499,31 @@ static void tree_element_grease_pencil_node_activate(bContext *C,
|
||||
GreasePencil &grease_pencil = *(GreasePencil *)tselem->id;
|
||||
bke::greasepencil::TreeNode &node = tree_element_cast<TreeElementGreasePencilNode>(te)->node();
|
||||
|
||||
if (node.is_layer()) {
|
||||
if (grease_pencil.has_active_group()) {
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
}
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
}
|
||||
if (node.is_group()) {
|
||||
if (grease_pencil.has_active_layer()) {
|
||||
WM_msg_publish_rna_prop(
|
||||
CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
|
||||
}
|
||||
WM_msg_publish_rna_prop(CTX_wm_message_bus(C),
|
||||
&grease_pencil.id,
|
||||
&grease_pencil,
|
||||
GreasePencilv3LayerGroup,
|
||||
active);
|
||||
}
|
||||
|
||||
grease_pencil.set_active_node(&node);
|
||||
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, &grease_pencil);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user