MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / duplicate_container

Method duplicate_container

src/session/src/session_actor.cpp:2181–2231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2179// I think the actors themselves need to support a clone atom..
2180
2181void SessionActor::duplicate_container(
2182 caf::typed_response_promise<UuidVector> rp,
2183 const utility::UuidTree<utility::PlaylistItem> &tree,
2184 caf::actor source_session,
2185 const utility::Uuid &uuid_before,
2186 const bool into,
2187 const bool rename,
2188 const bool kill_source) {
2189
2190 // find all actor children.. (Timeline/SUBSET/CONTACTSHEET)
2191 // quick clone of divider..
2192
2193 // clone structure
2194 PlaylistTree new_tree(tree);
2195
2196 // regenerate uuids..
2197 new_tree.reset_uuid(true);
2198
2199 duplicate_tree(new_tree, source_session, rename);
2200
2201 std::function<void(const PlaylistTree &, std::vector<Uuid> &)> flatten_tree;
2202 flatten_tree = [&flatten_tree](const PlaylistTree &tree, std::vector<Uuid> &rt) {
2203 rt.push_back(tree.uuid());
2204 for (auto i : tree.children_ref()) {
2205 flatten_tree(i, rt);
2206 }
2207 };
2208
2209 std::vector<Uuid> ordered_uuids;
2210
2211 // If we clone a session we need to reparent the children of the tree.
2212 // As they sit under the session item.
2213 if (new_tree.value().type() == "Session" or new_tree.value().type() == "") {
2214 // reparent..
2215 for (auto &i : new_tree.children_) {
2216 flatten_tree(i, ordered_uuids);
2217 base_.insert_container(i, uuid_before, into);
2218 }
2219
2220 } else {
2221 flatten_tree(new_tree, ordered_uuids);
2222 base_.insert_container(new_tree, uuid_before, into);
2223 }
2224
2225 base_.send_changed();
2226
2227 if (kill_source)
2228 send_exit(source_session, caf::exit_reason::user_shutdown);
2229
2230 rp.deliver(ordered_uuids);
2231}
2232
2233// session actors container groups/dividers and playlists..
2234void SessionActor::duplicate_tree(

Callers

nothing calls this directly

Calls 8

push_backMethod · 0.80
send_changedMethod · 0.80
deliverMethod · 0.80
reset_uuidMethod · 0.45
uuidMethod · 0.45
typeMethod · 0.45
valueMethod · 0.45
insert_containerMethod · 0.45

Tested by

no test coverage detected