From 3729188f18376d42ed29fd82cd4a65fa8774cd35 Mon Sep 17 00:00:00 2001 From: Brenno Date: Thu, 18 Mar 2021 13:05:21 -0300 Subject: [PATCH] Protect against linking the tracked object with the parent clip --- src/TrackedObjectBBox.cpp | 12 +++++++++--- src/TrackedObjectBase.cpp | 13 +++++++------ src/TrackedObjectBase.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/TrackedObjectBBox.cpp b/src/TrackedObjectBBox.cpp index c58aaca9..19cc8092 100644 --- a/src/TrackedObjectBBox.cpp +++ b/src/TrackedObjectBBox.cpp @@ -378,9 +378,15 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root) if (!root["protobuf_data_path"].isNull()) protobufDataPath = root["protobuf_data_path"].asString(); - // Set the id of the child clio - if (!root["child_clip_id"].isNull()) - ChildClipId(root["child_clip_id"].asString()); + // Set the id of the child clip + // Does not allow to link to the parent clip + if (!root["child_clip_id"].isNull()){ + Clip* parentClip = (Clip *) ParentClip(); + + if(parentClip && (root["child_clip_id"].asString() != parentClip->Id())){ + ChildClipId(root["child_clip_id"].asString()); + } + } // Set the Keyframes by the given JSON object if (!root["delta_x"].isNull()) diff --git a/src/TrackedObjectBase.cpp b/src/TrackedObjectBase.cpp index 780a9f53..acdc9e39 100644 --- a/src/TrackedObjectBase.cpp +++ b/src/TrackedObjectBase.cpp @@ -33,16 +33,16 @@ #include #include - -namespace openshot{ +namespace openshot +{ // Blank constructor - TrackedObjectBase::TrackedObjectBase() : visible(1.0), draw_box(1) + TrackedObjectBase::TrackedObjectBase() : visible(1.0), draw_box(1) { // Initializes the id as "None" id = "None"; childClipId = "None"; - } + } // Default constructor TrackedObjectBase::TrackedObjectBase(std::string _id) : visible(1.0) @@ -51,7 +51,8 @@ namespace openshot{ childClipId = "None"; } - Json::Value TrackedObjectBase::add_property_choice_json(std::string name, int value, int selected_value) const { + Json::Value TrackedObjectBase::add_property_choice_json(std::string name, int value, int selected_value) const + { // Create choice Json::Value new_choice = Json::Value(Json::objectValue); new_choice["name"] = name; @@ -61,4 +62,4 @@ namespace openshot{ // return JsonValue return new_choice; } -} \ No newline at end of file +} // namespace openshot \ No newline at end of file diff --git a/src/TrackedObjectBase.h b/src/TrackedObjectBase.h index 20e70fcf..c0f6c660 100644 --- a/src/TrackedObjectBase.h +++ b/src/TrackedObjectBase.h @@ -55,7 +55,7 @@ namespace openshot { * predicted along the frames of a clip. */ class TrackedObjectBase { - private: + protected: std::string id; std::string childClipId;