From 2cf2c55f9b835eb4bbc033e3c57cdaf911c34fd8 Mon Sep 17 00:00:00 2001 From: Brenno Date: Mon, 12 Apr 2021 21:32:27 -0300 Subject: [PATCH] Changed None to empty string, corrected dynamic pointers --- src/Clip.cpp | 10 +++++----- src/EffectBase.cpp | 4 ++-- src/KeyFrame.cpp | 7 +++---- src/TrackedObjectBBox.cpp | 4 ++-- src/TrackedObjectBase.cpp | 8 ++++---- src/effects/Tracker.cpp | 2 +- tests/KeyFrame.cpp | 10 ++++++---- tests/KeyFrame_Tests.cpp | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index e94b7d0c..0d4068cf 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -749,7 +749,7 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const { if (!parentObjectId.empty()) { root["parentObjectId"] = add_property_json("Parent", 0.0, "string", parentObjectId, NULL, -1, -1, false, requested_frame); } else { - root["parentObjectId"] = add_property_json("Parent", 0.0, "string", "None", NULL, -1, -1, false, requested_frame); + root["parentObjectId"] = add_property_json("Parent", 0.0, "string", "", NULL, -1, -1, false, requested_frame); } // Add gravity choices (dropdown style) root["gravity"]["choices"].append(add_property_choice_json("Top Left", GRAVITY_TOP_LEFT, gravity)); @@ -766,16 +766,16 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const { root["scale"]["choices"].append(add_property_choice_json("Crop", SCALE_CROP, scale)); root["scale"]["choices"].append(add_property_choice_json("Best Fit", SCALE_FIT, scale)); root["scale"]["choices"].append(add_property_choice_json("Stretch", SCALE_STRETCH, scale)); - root["scale"]["choices"].append(add_property_choice_json("None", SCALE_NONE, scale)); + root["scale"]["choices"].append(add_property_choice_json("", SCALE_NONE, scale)); // Add frame number display choices (dropdown style) - root["display"]["choices"].append(add_property_choice_json("None", FRAME_DISPLAY_NONE, display)); + root["display"]["choices"].append(add_property_choice_json("", FRAME_DISPLAY_NONE, display)); root["display"]["choices"].append(add_property_choice_json("Clip", FRAME_DISPLAY_CLIP, display)); root["display"]["choices"].append(add_property_choice_json("Timeline", FRAME_DISPLAY_TIMELINE, display)); root["display"]["choices"].append(add_property_choice_json("Both", FRAME_DISPLAY_BOTH, display)); // Add volume mixing choices (dropdown style) - root["mixing"]["choices"].append(add_property_choice_json("None", VOLUME_MIX_NONE, mixing)); + root["mixing"]["choices"].append(add_property_choice_json("", VOLUME_MIX_NONE, mixing)); root["mixing"]["choices"].append(add_property_choice_json("Average", VOLUME_MIX_AVERAGE, mixing)); root["mixing"]["choices"].append(add_property_choice_json("Reduce", VOLUME_MIX_REDUCE, mixing)); @@ -962,7 +962,7 @@ void Clip::SetJsonValue(const Json::Value root) { // Set data from Json (if key is found) if (!root["parentObjectId"].isNull()){ parentObjectId = root["parentObjectId"].asString(); - if (parentObjectId.size() > 0 && parentObjectId != "None"){ + if (parentObjectId.size() > 0 && parentObjectId != ""){ AttachToObject(parentObjectId); } else{ parentTrackedObject = nullptr; diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index 8f453ca5..97e1ef5e 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -52,7 +52,7 @@ void EffectBase::InitEffectInfo() info.has_tracked_object = false; info.name = ""; info.description = ""; - info.parent_effect_id = "None"; + info.parent_effect_id = ""; } // Display file information @@ -160,7 +160,7 @@ void EffectBase::SetJsonValue(Json::Value root) { if (!root["parent_effect_id"].isNull()){ info.parent_effect_id = root["parent_effect_id"].asString(); - if (info.parent_effect_id.size() > 0 && info.parent_effect_id != "None" && parentEffect == NULL) + if (info.parent_effect_id.size() > 0 && info.parent_effect_id != "" && parentEffect == NULL) SetParentEffect(info.parent_effect_id); else parentEffect = NULL; diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 421a562e..048ef931 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -34,9 +34,9 @@ #include #include #include -#include // For assert() -#include // For std::cout -#include // For std::setprecision +#include // For assert() +#include // For std::cout +#include // For std::setprecision using namespace std; using namespace openshot; @@ -92,7 +92,6 @@ namespace openshot{ t_step /= 2; } while (true); } - // Interpolate two points using the right Point's interpolation method double InterpolateBetween(Point const & left, Point const & right, double target, double allowed_error) { assert(left.co.X < target); diff --git a/src/TrackedObjectBBox.cpp b/src/TrackedObjectBBox.cpp index 89982932..447efaf2 100644 --- a/src/TrackedObjectBBox.cpp +++ b/src/TrackedObjectBBox.cpp @@ -370,7 +370,7 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root) { // Set the Id by the given JSON object - if (!root["box_id"].isNull() && root["box_id"].asString() != "None") + if (!root["box_id"].isNull() && root["box_id"].asString() != "") Id(root["box_id"].asString()); // Set the BaseFps by the given JSON object @@ -395,7 +395,7 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root) // Set the id of the child clip // Does not allow to link to the parent clip - if (!root["child_clip_id"].isNull() && root["box_id"].asString() != "None"){ + if (!root["child_clip_id"].isNull() && root["box_id"].asString() != ""){ Clip* parentClip = (Clip *) ParentClip(); if(parentClip && (root["child_clip_id"].asString() != parentClip->Id())){ diff --git a/src/TrackedObjectBase.cpp b/src/TrackedObjectBase.cpp index acdc9e39..631e0a65 100644 --- a/src/TrackedObjectBase.cpp +++ b/src/TrackedObjectBase.cpp @@ -39,16 +39,16 @@ namespace openshot // Blank constructor TrackedObjectBase::TrackedObjectBase() : visible(1.0), draw_box(1) { - // Initializes the id as "None" - id = "None"; - childClipId = "None"; + // Initializes the id as "" + id = ""; + childClipId = ""; } // Default constructor TrackedObjectBase::TrackedObjectBase(std::string _id) : visible(1.0) { Id(_id); - childClipId = "None"; + childClipId = ""; } Json::Value TrackedObjectBase::add_property_choice_json(std::string name, int value, int selected_value) const diff --git a/src/effects/Tracker.cpp b/src/effects/Tracker.cpp index 52dc9079..c4373d66 100644 --- a/src/effects/Tracker.cpp +++ b/src/effects/Tracker.cpp @@ -132,7 +132,7 @@ std::shared_ptr Tracker::GetFrame(std::shared_ptr frame, int64_t f } // Get the image of the Tracked Object' child clip - if (trackedData->ChildClipId() != "None"){ + if (trackedData->ChildClipId() != ""){ // Cast the parent timeline of this effect Timeline* parentTimeline = (Timeline *) ParentTimeline(); if (parentTimeline){ diff --git a/tests/KeyFrame.cpp b/tests/KeyFrame.cpp index 3e0b381c..a75e5a95 100644 --- a/tests/KeyFrame.cpp +++ b/tests/KeyFrame.cpp @@ -693,8 +693,9 @@ TEST_CASE( "AttachToObject", "[libopenshot][keyframe]" ) auto trackedDataJson = trackedData->JsonValue(); // Get and cast the trakcedObject - auto trackedObject_base = t.GetTrackedObject("None"); - std::shared_ptr trackedObject = std::static_pointer_cast(trackedObject_base); + auto trackedObject_base = t.GetTrackedObject(""); + auto trackedObject = std::make_shared(); + trackedObject = std::dynamic_pointer_cast(trackedObject_base); CHECK(trackedObject == trackedData); // Set trackedObject Json Value @@ -705,7 +706,8 @@ TEST_CASE( "AttachToObject", "[libopenshot][keyframe]" ) childClip.Open(); childClip.AttachToObject(tracked_id); - std::shared_ptr trackedTest = std::static_pointer_cast(childClip.GetAttachedObject()); + auto trackedTest = std::make_shared(); + trackedTest = std::dynamic_pointer_cast(childClip.GetAttachedObject()); CHECK(trackedData->scale_x.GetValue(1) == trackedTest->scale_x.GetValue(1)); @@ -719,7 +721,7 @@ TEST_CASE( "GetBoxValues", "[libopenshot][keyframe]" ) TrackedObjectBBox trackedDataObject; trackedDataObject.AddBox(1, 10.0, 10.0, 20.0, 20.0, 30.0); - std::shared_ptr trackedData = std::make_shared(trackedDataObject); + auto trackedData = std::make_shared(trackedDataObject); auto boxValues = trackedData->GetBoxValues(1); diff --git a/tests/KeyFrame_Tests.cpp b/tests/KeyFrame_Tests.cpp index 29c774be..33d0f7ae 100644 --- a/tests/KeyFrame_Tests.cpp +++ b/tests/KeyFrame_Tests.cpp @@ -670,7 +670,7 @@ TEST(Attach_test){ auto trackedDataJson = trackedData->JsonValue(); // Get and cast the trakcedObject - auto trackedObject_base = t.GetTrackedObject("None"); + auto trackedObject_base = t.GetTrackedObject(""); std::shared_ptr trackedObject = std::static_pointer_cast(trackedObject_base); CHECK_EQUAL(trackedData, trackedObject);