Use more make_unique

Shuts up a bunch of Coverity false-positives and might fix a true
positive or two.
This commit is contained in:
Thomas Goyne 2013-10-23 14:43:05 -07:00
parent da5445a09f
commit 01a38a5e86
12 changed files with 25 additions and 15 deletions

View file

@ -39,6 +39,7 @@
#include <libaegisub/of_type_adaptor.h>
#include <libaegisub/split.h>
#include <libaegisub/util.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/join.hpp>

View file

@ -555,10 +555,10 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C
: wxWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxBORDER_SIMPLE)
, audio_open_connection(controller->AddAudioOpenListener(&AudioDisplay::OnAudioOpen, this))
, context(context)
, audio_renderer(new AudioRenderer)
, audio_renderer(agi::util::make_unique<AudioRenderer>())
, controller(controller)
, scrollbar(new AudioDisplayScrollbar(this))
, timeline(new AudioDisplayTimeline(this))
, scrollbar(agi::util::make_unique<AudioDisplayScrollbar>(this))
, timeline(agi::util::make_unique<AudioDisplayTimeline>(this))
, dragged_object(0)
, scroll_left(0)
, pixel_audio_width(0)

View file

@ -37,6 +37,8 @@
#include "selection_controller.h"
#include "utils.h"
#include <libaegisub/util.h>
#include <algorithm>
#include <boost/locale/boundary.hpp>
#include <numeric>
@ -67,7 +69,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
, audio_closed(c->audioController->AddAudioCloseListener(&AudioKaraoke::OnAudioClosed, this))
, active_line_changed(c->selectionController->AddActiveLineListener(&AudioKaraoke::OnActiveLineChanged, this))
, active_line(nullptr)
, kara(new AssKaraoke)
, kara(agi::util::make_unique<AssKaraoke>())
, scroll_x(0)
, scroll_dir(0)
, char_height(0)

View file

@ -50,7 +50,7 @@ AudioMarkerProviderKeyframes::AudioMarkerProviderKeyframes(agi::Context *c, cons
, timecode_slot(vc->AddTimecodesListener(&AudioMarkerProviderKeyframes::Update, this))
, enabled_slot(OPT_SUB(opt_name, &AudioMarkerProviderKeyframes::Update, this))
, enabled_opt(OPT_GET(opt_name))
, style(new Pen("Colour/Audio Display/Keyframe"))
, style(agi::util::make_unique<Pen>("Colour/Audio Display/Keyframe"))
{
Update();
}
@ -139,7 +139,7 @@ void VideoPositionMarkerProvider::GetMarkers(const TimeRange &range, AudioMarker
}
SecondsMarkerProvider::SecondsMarkerProvider()
: pen(new Pen("Colour/Audio Display/Seconds Line", 1, wxPENSTYLE_DOT))
: pen(agi::util::make_unique<Pen>("Colour/Audio Display/Seconds Line", 1, wxPENSTYLE_DOT))
, enabled(OPT_GET("Audio/Display/Draw/Seconds"))
, enabled_opt_changed(OPT_SUB("Audio/Display/Draw/Seconds", &SecondsMarkerProvider::EnabledOptChanged, this))
{

View file

@ -365,7 +365,7 @@ do_setup:
AlsaPlayer::AlsaPlayer(AudioProvider *provider)
: AudioPlayer(provider)
, ps(new PlaybackState)
, ps(agi::util::make_unique<PlaybackState>())
{
ps->provider = provider;

View file

@ -46,6 +46,7 @@
#include "utils.h"
#include <libaegisub/charset_conv.h>
#include <libaegisub/util.h>
#include <algorithm>
#include <boost/filesystem/path.hpp>
@ -77,7 +78,7 @@ static void swap(wxCheckListBox *list, int idx, int sel_dir) {
DialogExport::DialogExport(agi::Context *c)
: wxDialog(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX)
, c(c)
, exporter(new AssExporter(c))
, exporter(agi::util::make_unique<AssExporter>(c))
{
SetIcon(GETICON(export_menu_16));
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);

View file

@ -30,6 +30,8 @@
#include "utils.h"
#include "validators.h"
#include <libaegisub/util.h>
#include <functional>
#include <wx/button.h>
@ -45,7 +47,7 @@
DialogSearchReplace::DialogSearchReplace(agi::Context* c, bool replace)
: wxDialog(c->parent, -1, replace ? _("Replace") : _("Find"))
, c(c)
, settings(new SearchReplaceSettings)
, settings(agi::util::make_unique<SearchReplaceSettings>())
, has_replace(replace)
{
auto recent_find(lagi_MRU_wxAS("Find"));

View file

@ -40,6 +40,7 @@
#include <libaegisub/log.h>
#include <libaegisub/of_type_adaptor.h>
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/cajun/elements.h>
#include <libaegisub/cajun/reader.h>
@ -100,7 +101,7 @@ DialogShiftTimes::DialogShiftTimes(agi::Context *context)
: wxDialog(context->parent, -1, _("Shift Times"))
, context(context)
, history_filename(config::path->Decode("?user/shift_history.json"))
, history(new json::Array)
, history(agi::util::make_unique<json::Array>())
, timecodes_loaded_slot(context->videoController->AddTimecodesListener(&DialogShiftTimes::OnTimecodesLoaded, this))
, selected_set_changed_slot(context->selectionController->AddSelectionListener(&DialogShiftTimes::OnSelectedSetChanged, this))
{

View file

@ -182,7 +182,7 @@ public:
FrameMain::FrameMain()
: wxFrame(nullptr, -1, "", wxDefaultPosition, wxSize(920,700), wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
, context(new agi::Context)
, context(agi::util::make_unique<agi::Context>())
, showVideo(true)
, showAudio(true)
, blockVideoLoad(false)

View file

@ -25,6 +25,7 @@
#include <libaegisub/exception.h>
#include <libaegisub/hotkey.h>
#include <libaegisub/util.h>
#include "command/command.h"
#include "command/icon.h"
@ -258,7 +259,7 @@ public:
HotkeyDataViewModel::HotkeyDataViewModel(Preferences *parent)
: root(new HotkeyModelRoot(this))
: root(agi::util::make_unique<HotkeyModelRoot>(this))
, parent(parent)
, has_pending_changes(false)
{

View file

@ -50,6 +50,7 @@
#include <libaegisub/ass/dialogue_parser.h>
#include <libaegisub/calltip_provider.h>
#include <libaegisub/spellchecker.h>
#include <libaegisub/util.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
@ -257,7 +258,7 @@ void SubsTextEditCtrl::UpdateCallTip() {
cursor_pos = pos;
if (!calltip_provider)
calltip_provider.reset(new agi::CalltipProvider);
calltip_provider = agi::util::make_unique<agi::CalltipProvider>();
agi::Calltip new_calltip = calltip_provider->GetCalltip(tokenized_line, line_text, pos);
@ -384,7 +385,7 @@ void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
if (currentWord.empty()) return;
if (!thesaurus)
thesaurus.reset(new Thesaurus);
thesaurus = agi::util::make_unique<Thesaurus>();
std::vector<Thesaurus::Entry> results;
thesaurus->Lookup(currentWord, &results);

View file

@ -27,12 +27,13 @@
#include "video_display.h"
#include <libaegisub/color.h>
#include <libaegisub/util.h>
#include <boost/format.hpp>
VisualToolCross::VisualToolCross(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualDraggableFeature>(parent, context)
, gl_text(new OpenGLText)
, gl_text(agi::util::make_unique<OpenGLText>())
{
parent->SetCursor(wxCursor(wxCURSOR_BLANK));
}