diff --git a/src/ass_override.cpp b/src/ass_override.cpp index bb7a540e1..8c4ca1a72 100644 --- a/src/ass_override.cpp +++ b/src/ass_override.cpp @@ -38,6 +38,7 @@ #include "utils.h" #include +#include #include #include @@ -113,7 +114,7 @@ template<> agi::Color AssOverrideParameter::Get() const { template<> AssDialogueBlockOverride *AssOverrideParameter::Get() const { if (!block.get()) { - block.reset(new AssDialogueBlockOverride(Get())); + block = agi::util::make_unique(Get()); block->ParseTags(); } return block.get(); diff --git a/src/ass_parser.cpp b/src/ass_parser.cpp index 1099cc7a7..eea747dc4 100644 --- a/src/ass_parser.cpp +++ b/src/ass_parser.cpp @@ -21,6 +21,8 @@ #include "ass_style.h" #include "subtitle_format.h" +#include + #include #include #include @@ -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(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(data, AssEntryGroup::GRAPHIC); } void AssParser::AddLine(std::string const& data) { diff --git a/src/audio_controller.cpp b/src/audio_controller.cpp index 38a764ae1..2018c3c9e 100644 --- a/src/audio_controller.cpp +++ b/src/audio_controller.cpp @@ -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; diff --git a/src/auto4_base.cpp b/src/auto4_base.cpp index dc73cd7c0..94a661de5 100644 --- a/src/auto4_base.cpp +++ b/src/auto4_base.cpp @@ -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()); diff --git a/src/auto4_base.h b/src/auto4_base.h index 21a93932c..da71c5eb6 100644 --- a/src/auto4_base.h +++ b/src/auto4_base.h @@ -71,7 +71,7 @@ namespace Automation4 { std::unique_ptr config_dialog; /// subclasses should implement this, producing a new ScriptDialog - virtual ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c) = 0; + virtual std::unique_ptr GenerateConfigDialog(wxWindow *parent, agi::Context *c) = 0; protected: std::string GetScriptSettingsIdentifier(); diff --git a/src/auto4_lua.cpp b/src/auto4_lua.cpp index 194c110dc..8611cdbd8 100644 --- a/src/auto4_lua.cpp +++ b/src/auto4_lua.cpp @@ -1093,7 +1093,7 @@ namespace Automation4 { } } - ScriptDialog* LuaExportFilter::GenerateConfigDialog(wxWindow *parent, agi::Context *c) + std::unique_ptr 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{config_dialog}; } LuaScriptFactory::LuaScriptFactory() diff --git a/src/auto4_lua.h b/src/auto4_lua.h index 9695c3ad9..74da7af44 100644 --- a/src/auto4_lua.h +++ b/src/auto4_lua.h @@ -279,7 +279,7 @@ namespace Automation4 { LuaDialog *config_dialog; protected: - ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c) override; + std::unique_ptr GenerateConfigDialog(wxWindow *parent, agi::Context *c) override; public: LuaExportFilter(lua_State *L); diff --git a/src/dialog_fonts_collector.cpp b/src/dialog_fonts_collector.cpp index 3b62b42f9..a18fb1a0b 100644 --- a/src/dialog_fonts_collector.cpp +++ b/src/dialog_fonts_collector.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -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(destination.wstring()); if (out->IsOk()) - zip.reset(new wxZipOutputStream(*out)); + zip = agi::util::make_unique(*out); if (!out->IsOk() || !zip || !zip->IsOk()) { AppendText(wxString::Format(_("* Failed to open %s.\n"), destination.wstring()), 2); diff --git a/src/spellchecker_hunspell.cpp b/src/spellchecker_hunspell.cpp index 3da4d93e9..b908650ae 100644 --- a/src/spellchecker_hunspell.cpp +++ b/src/spellchecker_hunspell.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -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(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("utf-8", hunspell->get_dic_encoding()); + rconv = agi::util::make_unique(hunspell->get_dic_encoding(), "utf-8"); userDicPath = config::path->Decode("?user/dictionaries")/str(boost::format("user_%s.dic") % language); ReadUserDictionary(); diff --git a/src/subs_preview.cpp b/src/subs_preview.cpp index 11713ba7c..78aa11adf 100644 --- a/src/subs_preview.cpp +++ b/src/subs_preview.cpp @@ -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(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(w, h, -1); - vid.reset(new DummyVideoProvider(0.0, 10, w, h, back_color, true)); + vid = agi::util::make_unique(0.0, 10, w, h, back_color, true); try { if (!progress) progress = agi::util::make_unique(this); diff --git a/src/text_file_writer.cpp b/src/text_file_writer.cpp index 6de65a4d8..a0409f1ee 100644 --- a/src/text_file_writer.cpp +++ b/src/text_file_writer.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -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("utf-8", encoding.c_str(), true); try { // Write the BOM diff --git a/src/video_context.cpp b/src/video_context.cpp index 330fafa99..baca1f82e 100644 --- a/src/video_context.cpp +++ b/src/video_context.cpp @@ -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(filename, old_matrix, this, progress); video_provider = provider->GetVideoProvider(); video_filename = filename;