From cc7595e3c671295c9d9bc51508d510a7fb9c9f29 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Fri, 7 Mar 2014 16:44:49 -0800
Subject: [PATCH] Remove AssEntry::Clone

---
 aegisub/src/ass_attachment.h          |  1 -
 aegisub/src/ass_dialogue.cpp          |  6 ------
 aegisub/src/ass_dialogue.h            |  2 --
 aegisub/src/ass_entry.h               |  3 ---
 aegisub/src/ass_file.cpp              | 12 +++++++++---
 aegisub/src/ass_info.h                |  1 -
 aegisub/src/ass_style.h               |  1 -
 aegisub/src/dialog_style_manager.cpp  |  2 +-
 aegisub/src/threaded_frame_source.cpp |  2 +-
 9 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/aegisub/src/ass_attachment.h b/aegisub/src/ass_attachment.h
index ae1e02569..2f428b4b1 100644
--- a/aegisub/src/ass_attachment.h
+++ b/aegisub/src/ass_attachment.h
@@ -48,7 +48,6 @@ public:
 
 	std::string GetEntryData() const override { return entry_data;  }
 	AssEntryGroup Group() const override { return group; }
-	AssAttachment *Clone() const override { return new AssAttachment(*this); }
 
 	AssAttachment(AssAttachment const& rgt);
 	AssAttachment(std::string const& header, AssEntryGroup group);
diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp
index f75298d04..4918143c6 100644
--- a/aegisub/src/ass_dialogue.cpp
+++ b/aegisub/src/ass_dialogue.cpp
@@ -255,9 +255,3 @@ std::string AssDialogue::GetStrippedText() const {
 	boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
 	return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), "");
 }
-
-AssDialogue *AssDialogue::Clone() const {
-	auto clone = new AssDialogue(*this);
-	clone->Id = Id;
-	return clone;
-}
diff --git a/aegisub/src/ass_dialogue.h b/aegisub/src/ass_dialogue.h
index 03c2169b1..9d661ba84 100644
--- a/aegisub/src/ass_dialogue.h
+++ b/aegisub/src/ass_dialogue.h
@@ -177,8 +177,6 @@ public:
 	/// Does this line collide with the passed line?
 	bool CollidesWith(const AssDialogue *target) const;
 
-	AssDialogue *Clone() const override;
-
 	AssDialogue();
 	AssDialogue(AssDialogue const&);
 	AssDialogue(AssDialogueBase const&);
diff --git a/aegisub/src/ass_entry.h b/aegisub/src/ass_entry.h
index 12105e634..cfeb2dafb 100644
--- a/aegisub/src/ass_entry.h
+++ b/aegisub/src/ass_entry.h
@@ -50,9 +50,6 @@ class AssEntry : public boost::intrusive::make_list_base_hook<boost::intrusive::
 public:
 	virtual ~AssEntry() { }
 
-	/// Create a copy of this entry
-	virtual AssEntry *Clone() const=0;
-
 	/// Section of the file this entry belongs to
 	virtual AssEntryGroup Group() const=0;
 
diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp
index 40766223e..8375bcf1b 100644
--- a/aegisub/src/ass_file.cpp
+++ b/aegisub/src/ass_file.cpp
@@ -57,9 +57,15 @@ void AssFile::LoadDefault(bool include_dialogue_line) {
 AssFile::AssFile(const AssFile &from)
 : Info(from.Info)
 {
-	Styles.clone_from(from.Styles, std::mem_fun_ref(&AssStyle::Clone), [](AssStyle *e) { delete e; });
-	Events.clone_from(from.Events, std::mem_fun_ref(&AssDialogue::Clone), [](AssDialogue *e) { delete e; });
-	Attachments.clone_from(from.Attachments, std::mem_fun_ref(&AssAttachment::Clone), [](AssAttachment *e) { delete e; });
+	Styles.clone_from(from.Styles,
+		[](AssStyle const& e) { return new AssStyle(e); },
+		[](AssStyle *e) { delete e; });
+	Events.clone_from(from.Events,
+		[](AssDialogue const& e) { return new AssDialogue(e); },
+		[](AssDialogue *e) { delete e; });
+	Attachments.clone_from(from.Attachments,
+		[](AssAttachment const & e) { return new AssAttachment(e); },
+		[](AssAttachment *e) { delete e; });
 }
 
 void AssFile::swap(AssFile& from) throw() {
diff --git a/aegisub/src/ass_info.h b/aegisub/src/ass_info.h
index ab001da2c..32b7792ae 100644
--- a/aegisub/src/ass_info.h
+++ b/aegisub/src/ass_info.h
@@ -26,7 +26,6 @@ public:
 	AssInfo(AssInfo const& o) = default;
 	AssInfo(std::string key, std::string value) : key(std::move(key)), value(std::move(value)) { }
 
-	AssInfo *Clone() const override { return new AssInfo(*this); }
 	AssEntryGroup Group() const override { return AssEntryGroup::INFO; }
 	std::string GetEntryData() const override { return key + ": " + value; }
 	std::string GetSSAText() const override { return boost::iequals(key, "scripttype: v4.00+") ? "ScriptType: v4.00" : GetEntryData(); }
diff --git a/aegisub/src/ass_style.h b/aegisub/src/ass_style.h
index b558176ff..935329ebe 100644
--- a/aegisub/src/ass_style.h
+++ b/aegisub/src/ass_style.h
@@ -80,7 +80,6 @@ public:
 	std::string GetEntryData() const override { return data; }
 	std::string GetSSAText() const override;
 	AssEntryGroup Group() const override { return AssEntryGroup::STYLE; }
-	AssStyle *Clone() const override { return new AssStyle(*this); }
 
 	/// Convert an ASS alignment to the equivalent SSA alignment
 	static int AssToSsa(int ass_align);
diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp
index 1783a72f2..ca90d17ef 100644
--- a/aegisub/src/dialog_style_manager.cpp
+++ b/aegisub/src/dialog_style_manager.cpp
@@ -629,7 +629,7 @@ void DialogStyleManager::OnCurrentImport() {
 
 		// Copy
 		modified = true;
-		c->ass->Styles.push_back(*temp.GetStyle(styles[sel])->Clone());
+		c->ass->Styles.push_back(*new AssStyle(*temp.GetStyle(styles[sel])));
 	}
 
 	// Update
diff --git a/aegisub/src/threaded_frame_source.cpp b/aegisub/src/threaded_frame_source.cpp
index 52f48366d..b1075a38c 100644
--- a/aegisub/src/threaded_frame_source.cpp
+++ b/aegisub/src/threaded_frame_source.cpp
@@ -141,7 +141,7 @@ void ThreadedFrameSource::UpdateSubtitles(const AssFile *new_subs, std::set<cons
 	size_t i = 0;
 	for (auto const& e : new_subs->Events) {
 		if (changes.count(&e))
-			changed.emplace_back(i, e.Clone());
+			changed.emplace_back(i, new AssDialogue(e));
 		++i;
 	}
 
-- 
GitLab