diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index e22283fe7..b75a08206 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -29,6 +29,7 @@ */ #include "EffectBase.h" + #include "Exceptions.h" #include "Timeline.h" @@ -106,7 +107,7 @@ Json::Value EffectBase::JsonValue() const { } // Load JSON string into this object -void EffectBase::SetJson(std::string value) { +void EffectBase::SetJson(const std::string value) { // Parse JSON string into JSON objects try @@ -123,7 +124,7 @@ void EffectBase::SetJson(std::string value) { } // Load Json::Value into this object -void EffectBase::SetJsonValue(Json::Value root) { +void EffectBase::SetJsonValue(const Json::Value root) { if (ParentTimeline()){ // Get parent timeline @@ -133,34 +134,37 @@ void EffectBase::SetJsonValue(Json::Value root) { std::list effects = parentTimeline->ClipEffects(); // TODO: Fix recursive call for Object Detection - + // // Loop through the effects and check if we have a child effect linked to this effect for (auto const& effect : effects){ // Set the properties of all effects which parentEffect points to this if ((effect->info.parent_effect_id == this->Id()) && (effect->Id() != this->Id())) - effect->SetJsonValue(root); + effect->SetJsonValue(root); } } // Set this effect properties with the parent effect properties (except the id and parent_effect_id) + Json::Value my_root; if (parentEffect){ - root = parentEffect->JsonValue(); - root["id"] = this->Id(); - root["parent_effect_id"] = this->info.parent_effect_id; - } + my_root = parentEffect->JsonValue(); + my_root["id"] = this->Id(); + my_root["parent_effect_id"] = this->info.parent_effect_id; + } else { + my_root = root; + } // Set parent data - ClipBase::SetJsonValue(root); + ClipBase::SetJsonValue(my_root); // Set data from Json (if key is found) - if (!root["order"].isNull()) - Order(root["order"].asInt()); + if (!my_root["order"].isNull()) + Order(my_root["order"].asInt()); - if (!root["parent_effect_id"].isNull()){ - info.parent_effect_id = root["parent_effect_id"].asString(); + if (!my_root["parent_effect_id"].isNull()){ + info.parent_effect_id = my_root["parent_effect_id"].asString(); if (info.parent_effect_id.size() > 0 && info.parent_effect_id != "" && parentEffect == NULL) SetParentEffect(info.parent_effect_id); - else + else parentEffect = NULL; } } @@ -192,7 +196,7 @@ void EffectBase::ParentClip(openshot::ClipBase* new_clip) { // Set the parent effect from which this properties will be set to void EffectBase::SetParentEffect(std::string parentEffect_id) { - + // Get parent Timeline Timeline* parentTimeline = (Timeline *) ParentTimeline(); @@ -210,7 +214,7 @@ void EffectBase::SetParentEffect(std::string parentEffect_id) { EffectJSON["id"] = this->Id(); EffectJSON["parent_effect_id"] = this->info.parent_effect_id; this->SetJsonValue(EffectJSON); - } + } } return; } @@ -221,4 +225,4 @@ std::string EffectBase::ParentClipId() const{ return clip->Id(); else return ""; -} \ No newline at end of file +} diff --git a/src/EffectBase.h b/src/EffectBase.h index 6e7418506..16c1ba953 100644 --- a/src/EffectBase.h +++ b/src/EffectBase.h @@ -111,13 +111,13 @@ namespace openshot virtual std::string GetVisibleObjects(int64_t frame_number) const {return {}; }; // Get and Set JSON methods - virtual std::string Json() const = 0; ///< Generate JSON string of this object - virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object - virtual Json::Value JsonValue() const = 0; ///< Generate Json::Value for this object - virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::Value into this object + virtual std::string Json() const; ///< Generate JSON string of this object + virtual void SetJson(const std::string value); ///< Load JSON string into this object + virtual Json::Value JsonValue() const; ///< Generate Json::Value for this object + virtual void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object virtual std::string Json(int64_t requested_frame) const{ - return {}; + return ""; }; virtual void SetJson(int64_t requested_frame, const std::string value) { return; @@ -130,6 +130,7 @@ namespace openshot /// Set the order that this effect should be executed. void Order(int new_order) { order = new_order; } + virtual ~EffectBase() = default; };