Use more make_unique
This commit is contained in:
parent
c53e8f6139
commit
feec511227
12 changed files with 25 additions and 27 deletions
|
@ -38,6 +38,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include <libaegisub/color.h>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
@ -113,7 +114,7 @@ template<> agi::Color AssOverrideParameter::Get<agi::Color>() const {
|
|||
|
||||
template<> AssDialogueBlockOverride *AssOverrideParameter::Get<AssDialogueBlockOverride*>() const {
|
||||
if (!block.get()) {
|
||||
block.reset(new AssDialogueBlockOverride(Get<std::string>()));
|
||||
block = agi::util::make_unique<AssDialogueBlockOverride>(Get<std::string>());
|
||||
block->ParseTags();
|
||||
}
|
||||
return block.get();
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "ass_style.h"
|
||||
#include "subtitle_format.h"
|
||||
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
@ -103,12 +105,12 @@ void AssParser::ParseStyleLine(std::string const& data) {
|
|||
|
||||
void AssParser::ParseFontLine(std::string const& data) {
|
||||
if (boost::starts_with(data, "fontname: "))
|
||||
attach.reset(new AssAttachment(data, AssEntryGroup::FONT));
|
||||
attach = agi::util::make_unique<AssAttachment>(data, AssEntryGroup::FONT);
|
||||
}
|
||||
|
||||
void AssParser::ParseGraphicsLine(std::string const& data) {
|
||||
if (boost::starts_with(data, "filename: "))
|
||||
attach.reset(new AssAttachment(data, AssEntryGroup::GRAPHIC));
|
||||
attach = agi::util::make_unique<AssAttachment>(data, AssEntryGroup::GRAPHIC);
|
||||
}
|
||||
|
||||
void AssParser::AddLine(std::string const& data) {
|
||||
|
|
|
@ -168,17 +168,9 @@ void AudioController::OpenAudio(agi::fs::path const& url)
|
|||
}
|
||||
|
||||
CloseAudio();
|
||||
provider = std::move(new_provider);
|
||||
|
||||
try
|
||||
{
|
||||
player = AudioPlayerFactory::GetAudioPlayer(provider.get(), context->parent);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
provider.reset();
|
||||
throw;
|
||||
}
|
||||
player = AudioPlayerFactory::GetAudioPlayer(new_provider.get(), context->parent);
|
||||
provider = std::move(new_provider);
|
||||
|
||||
audio_url = url;
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace Automation4 {
|
|||
}
|
||||
|
||||
wxWindow* ExportFilter::GetConfigDialogWindow(wxWindow *parent, agi::Context *c) {
|
||||
config_dialog.reset(GenerateConfigDialog(parent, c));
|
||||
config_dialog = GenerateConfigDialog(parent, c);
|
||||
|
||||
if (config_dialog) {
|
||||
std::string val = c->ass->GetScriptInfo(GetScriptSettingsIdentifier());
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Automation4 {
|
|||
std::unique_ptr<ScriptDialog> config_dialog;
|
||||
|
||||
/// subclasses should implement this, producing a new ScriptDialog
|
||||
virtual ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c) = 0;
|
||||
virtual std::unique_ptr<ScriptDialog> GenerateConfigDialog(wxWindow *parent, agi::Context *c) = 0;
|
||||
|
||||
protected:
|
||||
std::string GetScriptSettingsIdentifier();
|
||||
|
|
|
@ -1093,7 +1093,7 @@ namespace Automation4 {
|
|||
}
|
||||
}
|
||||
|
||||
ScriptDialog* LuaExportFilter::GenerateConfigDialog(wxWindow *parent, agi::Context *c)
|
||||
std::unique_ptr<ScriptDialog> LuaExportFilter::GenerateConfigDialog(wxWindow *parent, agi::Context *c)
|
||||
{
|
||||
if (!has_config)
|
||||
return nullptr;
|
||||
|
@ -1119,7 +1119,7 @@ namespace Automation4 {
|
|||
config_dialog = new LuaDialog(L, false);
|
||||
}
|
||||
|
||||
return config_dialog;
|
||||
return std::unique_ptr<ScriptDialog>{config_dialog};
|
||||
}
|
||||
|
||||
LuaScriptFactory::LuaScriptFactory()
|
||||
|
|
|
@ -279,7 +279,7 @@ namespace Automation4 {
|
|||
LuaDialog *config_dialog;
|
||||
|
||||
protected:
|
||||
ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c) override;
|
||||
std::unique_ptr<ScriptDialog> GenerateConfigDialog(wxWindow *parent, agi::Context *c) override;
|
||||
|
||||
public:
|
||||
LuaExportFilter(lua_State *L);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <libaegisub/dispatch.h>
|
||||
#include <libaegisub/fs.h>
|
||||
#include <libaegisub/path.h>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/dirdlg.h>
|
||||
|
@ -110,9 +111,9 @@ void FontsCollectorThread(AssFile *subs, agi::fs::path const& destination, FcMod
|
|||
return;
|
||||
}
|
||||
|
||||
out.reset(new wxFFileOutputStream(destination.wstring()));
|
||||
out = agi::util::make_unique<wxFFileOutputStream>(destination.wstring());
|
||||
if (out->IsOk())
|
||||
zip.reset(new wxZipOutputStream(*out));
|
||||
zip = agi::util::make_unique<wxZipOutputStream>(*out);
|
||||
|
||||
if (!out->IsOk() || !zip || !zip->IsOk()) {
|
||||
AppendText(wxString::Format(_("* Failed to open %s.\n"), destination.wstring()), 2);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <libaegisub/line_iterator.h>
|
||||
#include <libaegisub/log.h>
|
||||
#include <libaegisub/path.h>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/range/algorithm.hpp>
|
||||
|
@ -197,11 +198,11 @@ void HunspellSpellChecker::OnLanguageChanged() {
|
|||
|
||||
LOG_I("dictionary/file") << dic;
|
||||
|
||||
hunspell.reset(new Hunspell(agi::fs::ShortName(aff).c_str(), agi::fs::ShortName(dic).c_str()));
|
||||
hunspell = agi::util::make_unique<Hunspell>(agi::fs::ShortName(aff).c_str(), agi::fs::ShortName(dic).c_str());
|
||||
if (!hunspell) return;
|
||||
|
||||
conv.reset(new agi::charset::IconvWrapper("utf-8", hunspell->get_dic_encoding()));
|
||||
rconv.reset(new agi::charset::IconvWrapper(hunspell->get_dic_encoding(), "utf-8"));
|
||||
conv = agi::util::make_unique<agi::charset::IconvWrapper>("utf-8", hunspell->get_dic_encoding());
|
||||
rconv = agi::util::make_unique<agi::charset::IconvWrapper>(hunspell->get_dic_encoding(), "utf-8");
|
||||
|
||||
userDicPath = config::path->Decode("?user/dictionaries")/str(boost::format("user_%s.dic") % language);
|
||||
ReadUserDictionary();
|
||||
|
|
|
@ -93,7 +93,7 @@ void SubtitlesPreview::SetText(std::string const& text) {
|
|||
void SubtitlesPreview::SetColour(agi::Color col) {
|
||||
if (col != back_color) {
|
||||
back_color = col;
|
||||
vid.reset(new DummyVideoProvider(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), back_color, true));
|
||||
vid = agi::util::make_unique<DummyVideoProvider>(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), back_color, true);
|
||||
UpdateBitmap();
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
|||
int h = evt.GetSize().GetHeight();
|
||||
|
||||
bmp = agi::util::make_unique<wxBitmap>(w, h, -1);
|
||||
vid.reset(new DummyVideoProvider(0.0, 10, w, h, back_color, true));
|
||||
vid = agi::util::make_unique<DummyVideoProvider>(0.0, 10, w, h, back_color, true);
|
||||
try {
|
||||
if (!progress)
|
||||
progress = agi::util::make_unique<DialogProgress>(this);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <libaegisub/io.h>
|
||||
#include <libaegisub/charset_conv.h>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
@ -36,7 +37,7 @@ TextFileWriter::TextFileWriter(agi::fs::path const& filename, std::string encodi
|
|||
if (encoding.empty())
|
||||
encoding = OPT_GET("App/Save Charset")->GetString();
|
||||
if (boost::iequals(encoding, "utf-8"))
|
||||
conv.reset(new agi::charset::IconvWrapper("utf-8", encoding.c_str(), true));
|
||||
conv = agi::util::make_unique<agi::charset::IconvWrapper>("utf-8", encoding.c_str(), true);
|
||||
|
||||
try {
|
||||
// Write the BOM
|
||||
|
|
|
@ -117,7 +117,7 @@ void VideoContext::SetVideo(const agi::fs::path &filename) {
|
|||
if (!progress)
|
||||
progress = new DialogProgress(context->parent);
|
||||
auto old_matrix = context->ass->GetScriptInfo("YCbCr Matrix");
|
||||
provider.reset(new ThreadedFrameSource(filename, old_matrix, this, progress));
|
||||
provider = agi::util::make_unique<ThreadedFrameSource>(filename, old_matrix, this, progress);
|
||||
video_provider = provider->GetVideoProvider();
|
||||
video_filename = filename;
|
||||
|
||||
|
|
Loading…
Reference in a new issue