From a7f4fb5b871d76c0f09791599ea6c41a477a60cb Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 21 Nov 2013 09:13:36 -0800 Subject: [PATCH] Run clang-modernize on things --- aegisub/libaegisub/common/charset.cpp | 15 ++- aegisub/libaegisub/common/charset_conv.cpp | 2 +- aegisub/libaegisub/common/dispatch.cpp | 6 +- aegisub/libaegisub/common/mru.cpp | 2 +- aegisub/libaegisub/common/option_visit.cpp | 4 +- aegisub/libaegisub/common/path.cpp | 6 +- aegisub/libaegisub/common/vfr.cpp | 4 +- .../include/libaegisub/cajun/reader.h | 10 +- .../include/libaegisub/cajun/writer.h | 14 +-- .../libaegisub/include/libaegisub/exception.h | 2 +- .../libaegisub/include/libaegisub/hotkey.h | 12 +-- .../include/libaegisub/line_iterator.h | 2 +- .../libaegisub/include/libaegisub/line_wrap.h | 6 +- aegisub/libaegisub/include/libaegisub/log.h | 4 +- aegisub/libaegisub/include/libaegisub/mru.h | 2 +- .../libaegisub/include/libaegisub/signal.h | 2 +- aegisub/libaegisub/include/libaegisub/vfr.h | 2 +- aegisub/src/aegisublocale.cpp | 8 +- aegisub/src/ass_attachment.cpp | 2 +- aegisub/src/ass_dialogue.cpp | 12 +-- aegisub/src/ass_dialogue.h | 4 +- aegisub/src/ass_export_filter.cpp | 6 +- aegisub/src/ass_export_filter.h | 6 +- aegisub/src/ass_exporter.h | 2 +- aegisub/src/ass_file.h | 2 +- aegisub/src/ass_info.h | 2 +- aegisub/src/ass_karaoke.cpp | 2 +- aegisub/src/ass_karaoke.h | 2 +- aegisub/src/ass_override.cpp | 2 +- aegisub/src/ass_parser.cpp | 2 +- aegisub/src/ass_style.cpp | 8 +- aegisub/src/ass_style_storage.cpp | 2 +- aegisub/src/ass_time.cpp | 6 +- aegisub/src/ass_time.h | 2 +- aegisub/src/audio_box.cpp | 4 +- aegisub/src/audio_colorscheme.cpp | 2 +- aegisub/src/audio_controller.cpp | 6 +- aegisub/src/audio_display.cpp | 22 ++-- aegisub/src/audio_karaoke.cpp | 8 +- aegisub/src/audio_marker.cpp | 16 +-- aegisub/src/audio_marker.h | 14 +-- aegisub/src/audio_player.cpp | 4 +- aegisub/src/audio_player_openal.cpp | 18 ++-- aegisub/src/audio_player_openal.h | 16 +-- aegisub/src/audio_provider.cpp | 10 +- aegisub/src/audio_provider_convert.cpp | 18 ++-- aegisub/src/audio_provider_dummy.h | 2 +- aegisub/src/audio_provider_ffmpegsource.cpp | 16 +-- aegisub/src/audio_provider_ffmpegsource.h | 4 +- aegisub/src/audio_provider_hd.cpp | 2 +- aegisub/src/audio_provider_hd.h | 2 +- aegisub/src/audio_provider_lock.h | 2 +- aegisub/src/audio_provider_pcm.cpp | 32 +++--- aegisub/src/audio_provider_pcm.h | 2 +- aegisub/src/audio_provider_ram.cpp | 2 +- aegisub/src/audio_provider_ram.h | 2 +- aegisub/src/audio_renderer.cpp | 4 +- aegisub/src/audio_renderer.h | 2 +- aegisub/src/audio_renderer_spectrum.cpp | 14 +-- aegisub/src/audio_renderer_spectrum.h | 8 +- aegisub/src/audio_renderer_waveform.cpp | 6 +- aegisub/src/audio_renderer_waveform.h | 10 +- aegisub/src/audio_timing_dialogue.cpp | 52 ++++----- aegisub/src/audio_timing_karaoke.cpp | 48 ++++----- aegisub/src/auto4_base.cpp | 16 +-- aegisub/src/auto4_base.h | 42 ++++---- aegisub/src/auto4_lua.cpp | 34 +++--- aegisub/src/auto4_lua.h | 26 ++--- aegisub/src/auto4_lua_assfile.cpp | 6 +- aegisub/src/auto4_lua_dialog.cpp | 88 +++++++-------- aegisub/src/auto4_lua_progresssink.cpp | 2 +- aegisub/src/base_grid.cpp | 6 +- aegisub/src/base_grid.h | 16 +-- aegisub/src/block_cache.h | 4 +- aegisub/src/colour_button.cpp | 2 +- aegisub/src/colour_button.h | 8 +- aegisub/src/command/app.cpp | 48 ++++----- aegisub/src/command/audio.cpp | 86 +++++++-------- aegisub/src/command/automation.cpp | 8 +- aegisub/src/command/command.cpp | 2 +- aegisub/src/command/edit.cpp | 100 ++++++++--------- aegisub/src/command/grid.cpp | 60 +++++------ aegisub/src/command/help.cpp | 14 +-- aegisub/src/command/icon.cpp | 2 +- aegisub/src/command/keyframe.cpp | 10 +- aegisub/src/command/subtitle.cpp | 52 ++++----- aegisub/src/command/time.cpp | 40 +++---- aegisub/src/command/timecode.cpp | 10 +- aegisub/src/command/tool.cpp | 38 +++---- aegisub/src/command/video.cpp | 102 +++++++++--------- aegisub/src/command/vis_tool.cpp | 6 +- aegisub/src/dialog_automation.cpp | 2 +- aegisub/src/dialog_autosave.h | 4 +- aegisub/src/dialog_colorpicker.cpp | 24 ++--- aegisub/src/dialog_detached_video.cpp | 2 +- aegisub/src/dialog_dummy_video.cpp | 10 +- aegisub/src/dialog_export_ebu3264.cpp | 8 +- aegisub/src/dialog_jumpto.cpp | 2 +- aegisub/src/dialog_kara_timing_copy.cpp | 4 +- aegisub/src/dialog_log.cpp | 2 +- aegisub/src/dialog_progress.cpp | 12 +-- aegisub/src/dialog_progress.h | 2 +- aegisub/src/dialog_properties.cpp | 4 +- aegisub/src/dialog_selected_choices.cpp | 2 +- aegisub/src/dialog_selection.cpp | 2 +- aegisub/src/dialog_spellchecker.cpp | 6 +- aegisub/src/dialog_style_editor.cpp | 12 +-- aegisub/src/dialog_styling_assistant.cpp | 4 +- aegisub/src/dialog_timing_processor.cpp | 4 +- aegisub/src/dialog_translation.cpp | 4 +- aegisub/src/dialog_version_check.cpp | 12 +-- aegisub/src/dialog_video_details.cpp | 4 +- aegisub/src/export_fixstyle.h | 2 +- aegisub/src/export_framerate.cpp | 8 +- aegisub/src/export_framerate.h | 6 +- aegisub/src/font_file_lister.cpp | 8 +- aegisub/src/font_file_lister_fontconfig.h | 2 +- aegisub/src/frame_main.cpp | 18 ++-- aegisub/src/help_button.cpp | 4 +- aegisub/src/hotkey.cpp | 18 ++-- aegisub/src/hotkey_data_view_model.cpp | 32 +++--- aegisub/src/hotkey_data_view_model.h | 14 +-- aegisub/src/main.cpp | 4 +- aegisub/src/main.h | 14 +-- aegisub/src/menu.cpp | 12 +-- aegisub/src/persist_location.cpp | 4 +- aegisub/src/placeholder_ctrl.h | 2 +- aegisub/src/preferences.cpp | 32 +++--- aegisub/src/preferences_base.cpp | 6 +- aegisub/src/preferences_base.h | 2 +- .../src/scintilla_text_selection_controller.h | 10 +- aegisub/src/search_replace_engine.cpp | 2 +- aegisub/src/spellchecker_hunspell.cpp | 4 +- aegisub/src/spellchecker_hunspell.h | 14 +-- aegisub/src/spline.cpp | 18 ++-- aegisub/src/spline_curve.cpp | 6 +- aegisub/src/subs_edit_box.cpp | 4 +- aegisub/src/subs_edit_ctrl.cpp | 10 +- aegisub/src/subs_edit_ctrl.h | 2 +- aegisub/src/subs_preview.cpp | 2 +- aegisub/src/subtitle_format.cpp | 14 +-- aegisub/src/subtitle_format.h | 2 +- aegisub/src/subtitle_format_ass.cpp | 2 +- aegisub/src/subtitle_format_ebu3264.cpp | 8 +- aegisub/src/subtitle_format_microdvd.cpp | 2 +- aegisub/src/subtitle_format_srt.cpp | 8 +- aegisub/src/subtitle_format_transtation.cpp | 2 +- aegisub/src/subtitle_format_ttxt.cpp | 16 +-- aegisub/src/subtitle_format_txt.cpp | 4 +- aegisub/src/subtitles_provider_libass.h | 4 +- aegisub/src/threaded_frame_source.cpp | 4 +- aegisub/src/threaded_frame_source.h | 16 +-- aegisub/src/toolbar.cpp | 16 +-- aegisub/src/validators.cpp | 4 +- aegisub/src/validators.h | 12 +-- aegisub/src/vector2d.cpp | 2 +- aegisub/src/video_box.cpp | 4 +- aegisub/src/video_display.cpp | 8 +- aegisub/src/video_out_gl.h | 8 +- aegisub/src/video_provider_cache.h | 20 ++-- aegisub/src/video_provider_dummy.h | 18 ++-- aegisub/src/video_provider_ffmpegsource.h | 20 ++-- aegisub/src/video_provider_yuv4mpeg.h | 20 ++-- aegisub/src/visual_tool.cpp | 8 +- aegisub/src/visual_tool.h | 2 +- aegisub/src/visual_tool_clip.cpp | 6 +- aegisub/src/visual_tool_clip.h | 14 +-- aegisub/src/visual_tool_cross.h | 4 +- aegisub/src/visual_tool_drag.cpp | 4 +- aegisub/src/visual_tool_drag.h | 18 ++-- aegisub/src/visual_tool_rotatexy.h | 10 +- aegisub/src/visual_tool_rotatez.h | 10 +- aegisub/src/visual_tool_scale.h | 8 +- aegisub/src/visual_tool_vector_clip.h | 14 +-- aegisub/tests/tests/iconv.cpp | 2 +- aegisub/tests/tests/line_iterator.cpp | 26 ++--- aegisub/tests/tests/mru.cpp | 4 +- aegisub/tests/tests/option.cpp | 2 +- aegisub/tests/tests/syntax_highlight.cpp | 18 ++-- aegisub/tests/tests/thesaurus.cpp | 2 +- 180 files changed, 1045 insertions(+), 1048 deletions(-) diff --git a/aegisub/libaegisub/common/charset.cpp b/aegisub/libaegisub/common/charset.cpp index 8ad4df4b6..1b39b52f9 100644 --- a/aegisub/libaegisub/common/charset.cpp +++ b/aegisub/libaegisub/common/charset.cpp @@ -39,7 +39,7 @@ class UCDetect : public nsUniversalDetector { /// List of detected character sets CharsetListDetected list; - void Report(const char* aCharset) {} + void Report(const char*) override {} public: /// @brief Detect character set of a file using UniversalCharDetect @@ -90,17 +90,16 @@ public: list.emplace_back(1.f, mDetectedCharset); else { switch (mInputState) { - case eHighbyte: { - for (PRInt32 i=0; iGetConfidence(); + float conf = elem->GetConfidence(); if (conf > 0.01f) - list.emplace_back(conf, mCharSetProbers[i]->GetCharSetName()); + list.emplace_back(conf, elem->GetCharSetName()); } - break; - } + case ePureAscii: list.emplace_back(1.f, "US-ASCII"); break; diff --git a/aegisub/libaegisub/common/charset_conv.cpp b/aegisub/libaegisub/common/charset_conv.cpp index 7d537680f..0865ae4ea 100644 --- a/aegisub/libaegisub/common/charset_conv.cpp +++ b/aegisub/libaegisub/common/charset_conv.cpp @@ -241,7 +241,7 @@ namespace { ~ConverterImpl() { if (cd != iconv_invalid) iconv_close(cd); } - size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) { + size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) override { eat_bom(cd, bomSize, inbuf, inbytesleft, outbuf, outbytesleft); size_t res = iconv(cd, ICONV_CONST_CAST(inbuf), inbytesleft, outbuf, outbytesleft); diff --git a/aegisub/libaegisub/common/dispatch.cpp b/aegisub/libaegisub/common/dispatch.cpp index bd4a26f59..e3a5baa02 100644 --- a/aegisub/libaegisub/common/dispatch.cpp +++ b/aegisub/libaegisub/common/dispatch.cpp @@ -33,13 +33,13 @@ namespace { std::atomic threads_running; class MainQueue : public agi::dispatch::Queue { - void DoInvoke(agi::dispatch::Thunk thunk) { + void DoInvoke(agi::dispatch::Thunk thunk) override { invoke_main(thunk); } }; class BackgroundQueue : public agi::dispatch::Queue { - void DoInvoke(agi::dispatch::Thunk thunk) { + void DoInvoke(agi::dispatch::Thunk thunk) override { service->post(thunk); } }; @@ -47,7 +47,7 @@ namespace { class SerialQueue : public agi::dispatch::Queue { boost::asio::io_service::strand strand; - void DoInvoke(agi::dispatch::Thunk thunk) { + void DoInvoke(agi::dispatch::Thunk thunk) override { strand.post(thunk); } public: diff --git a/aegisub/libaegisub/common/mru.cpp b/aegisub/libaegisub/common/mru.cpp index 3e32b5670..a84dc96c7 100644 --- a/aegisub/libaegisub/common/mru.cpp +++ b/aegisub/libaegisub/common/mru.cpp @@ -56,7 +56,7 @@ MRUManager::~MRUManager() { } MRUManager::MRUListMap &MRUManager::Find(std::string const& key) { - MRUMap::iterator index = mru.find(key); + auto index = mru.find(key); if (index == mru.end()) throw MRUErrorInvalidKey("Invalid key value"); return index->second; diff --git a/aegisub/libaegisub/common/option_visit.cpp b/aegisub/libaegisub/common/option_visit.cpp index 28a1e62b0..2e99ef240 100644 --- a/aegisub/libaegisub/common/option_visit.cpp +++ b/aegisub/libaegisub/common/option_visit.cpp @@ -67,11 +67,11 @@ std::unique_ptr ConfigVisitor::ReadArray(json::Array const& src, st for (json::Object const& obj : src) { if (obj.size() != 1) { Error("Invalid array member"); - return 0; + return nullptr; } if (obj.begin()->first != array_type) { Error("Attempt to insert value into array of wrong type"); - return 0; + return nullptr; } arr.push_back(ValueType(obj.begin()->second)); diff --git a/aegisub/libaegisub/common/path.cpp b/aegisub/libaegisub/common/path.cpp index 680495b8a..d251c2f2a 100644 --- a/aegisub/libaegisub/common/path.cpp +++ b/aegisub/libaegisub/common/path.cpp @@ -66,7 +66,7 @@ fs::path Path::Decode(std::string const& path) const { fs::path Path::MakeRelative(fs::path const& path, std::string const& token) const { const auto it = tokens.find(token); - if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, 0); + if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, nullptr); return MakeRelative(path, it->second); } @@ -97,7 +97,7 @@ fs::path Path::MakeRelative(fs::path const& path, fs::path const& base) const { fs::path Path::MakeAbsolute(fs::path path, std::string const& token) const { const auto it = tokens.find(token); - if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, 0); + if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, nullptr); if (path.empty()) return path; path.make_preferred(); @@ -127,7 +127,7 @@ std::string Path::Encode(fs::path const& path) const { void Path::SetToken(std::string const& token_name, fs::path const& token_value) { const auto it = tokens.find(token_name); - if (it == tokens.end()) throw agi::InternalError("Bad token: " + token_name, 0); + if (it == tokens.end()) throw agi::InternalError("Bad token: " + token_name, nullptr); if (token_value.empty()) it->second = token_value; diff --git a/aegisub/libaegisub/common/vfr.cpp b/aegisub/libaegisub/common/vfr.cpp index 3f6b6fe12..a670eb5c7 100644 --- a/aegisub/libaegisub/common/vfr.cpp +++ b/aegisub/libaegisub/common/vfr.cpp @@ -179,8 +179,8 @@ void Framerate::SetFromTimecodes() { last = (timecodes.size() - 1) * denominator * 1000; } -Framerate::Framerate(std::vector const& timecodes) -: timecodes(timecodes) +Framerate::Framerate(std::vector timecodes) +: timecodes(std::move(timecodes)) , drop(false) { SetFromTimecodes(); diff --git a/aegisub/libaegisub/include/libaegisub/cajun/reader.h b/aegisub/libaegisub/include/libaegisub/cajun/reader.h index 794859870..a0d21c502 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/reader.h +++ b/aegisub/libaegisub/include/libaegisub/cajun/reader.h @@ -31,9 +31,9 @@ public: // problems such as errant characters or corrupt/incomplete documents class ScanException : public Exception { public: - ScanException(std::string const& sMessage, Reader::Location const& locError) + ScanException(std::string const& sMessage, Reader::Location locError) : Exception(sMessage) - , m_locError(locError) + , m_locError(std::move(locError)) { } Reader::Location m_locError; @@ -43,10 +43,10 @@ public: // higher-level problems such as missing commas or brackets class ParseException : public Exception { public: - ParseException(std::string const& sMessage, Reader::Location const& locTokenBegin, Reader::Location const& locTokenEnd) + ParseException(std::string const& sMessage, Reader::Location locTokenBegin, Reader::Location locTokenEnd) : Exception(sMessage) - , m_locTokenBegin(locTokenBegin) - , m_locTokenEnd(locTokenEnd) + , m_locTokenBegin(std::move(locTokenBegin)) + , m_locTokenEnd(std::move(locTokenEnd)) { } Reader::Location m_locTokenBegin; diff --git a/aegisub/libaegisub/include/libaegisub/cajun/writer.h b/aegisub/libaegisub/include/libaegisub/cajun/writer.h index 42e73b103..0eb4c94a2 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/writer.h +++ b/aegisub/libaegisub/include/libaegisub/cajun/writer.h @@ -26,13 +26,13 @@ class Writer : private ConstVisitor { void Write(const Null& null); void Write(const UnknownElement& unknown); - void Visit(const Array& array); - void Visit(const Object& object); - void Visit(const Integer& number); - void Visit(const Double& number); - void Visit(const String& string); - void Visit(const Boolean& boolean); - void Visit(const Null& null); + void Visit(const Array& array) override; + void Visit(const Object& object) override; + void Visit(const Integer& number) override; + void Visit(const Double& number) override; + void Visit(const String& string) override; + void Visit(const Boolean& boolean) override; + void Visit(const Null& null) override; std::ostream& m_ostr; int tab_depth; diff --git a/aegisub/libaegisub/include/libaegisub/exception.h b/aegisub/libaegisub/include/libaegisub/exception.h index 2290d80ad..a4094910d 100644 --- a/aegisub/libaegisub/include/libaegisub/exception.h +++ b/aegisub/libaegisub/include/libaegisub/exception.h @@ -100,7 +100,7 @@ namespace agi { /// /// Deriving classes should always use this constructor for initialising /// the base class. - Exception(const std::string &msg, const Exception *inr = 0) : message(msg) { + Exception(std::string msg, const Exception *inr = nullptr) : message(std::move(msg)) { if (inr) inner.reset(inr->Copy()); } diff --git a/aegisub/libaegisub/include/libaegisub/hotkey.h b/aegisub/libaegisub/include/libaegisub/hotkey.h index bf70771c6..394c19fc6 100644 --- a/aegisub/libaegisub/include/libaegisub/hotkey.h +++ b/aegisub/libaegisub/include/libaegisub/hotkey.h @@ -34,8 +34,8 @@ namespace agi { namespace hotkey { /// @class Combo -/// A Combo represents a linear sequence of characters set in an std::vector. This makes up -/// a single combination, or "Hotkey". +/// A Combo represents a linear sequence of characters set in an std::vector. +/// This makes up a single combination, or "Hotkey". class Combo { std::vector key_map; std::string cmd_name; @@ -44,10 +44,10 @@ public: /// Constructor /// @param ctx Context /// @param cmd Command name - Combo(std::string const& ctx, std::string const& cmd, std::vector const& keys) - : key_map(keys) - , cmd_name(cmd) - , context(ctx) + Combo(std::string ctx, std::string cmd, std::vector keys) + : key_map(std::move(keys)) + , cmd_name(std::move(cmd)) + , context(std::move(ctx)) { } diff --git a/aegisub/libaegisub/include/libaegisub/line_iterator.h b/aegisub/libaegisub/include/libaegisub/line_iterator.h index 43e88f03e..57f86ff14 100644 --- a/aegisub/libaegisub/include/libaegisub/line_iterator.h +++ b/aegisub/libaegisub/include/libaegisub/line_iterator.h @@ -85,7 +85,7 @@ public: /// @brief Invalid iterator constructor; use for end iterator line_iterator() - : stream(0) + : stream(nullptr) , valid(false) { } diff --git a/aegisub/libaegisub/include/libaegisub/line_wrap.h b/aegisub/libaegisub/include/libaegisub/line_wrap.h index e922e0faa..a5f7311c8 100644 --- a/aegisub/libaegisub/include/libaegisub/line_wrap.h +++ b/aegisub/libaegisub/include/libaegisub/line_wrap.h @@ -43,9 +43,9 @@ namespace agi { template inline void get_line_widths(StartCont const& line_start_points, Iter begin, Iter end, WidthCont &line_widths) { size_t line_start = 0; - for (size_t i = 0; i < line_start_points.size(); ++i) { - line_widths.push_back(std::accumulate(begin + line_start, begin + line_start_points[i], 0)); - line_start = line_start_points[i]; + for (auto & line_start_point : line_start_points) { + line_widths.push_back(std::accumulate(begin + line_start, begin + line_start_point, 0)); + line_start = line_start_point; } line_widths.push_back(std::accumulate(begin + line_start, end, 0)); } diff --git a/aegisub/libaegisub/include/libaegisub/log.h b/aegisub/libaegisub/include/libaegisub/log.h index bfa1bfb50..b87fd6032 100644 --- a/aegisub/libaegisub/include/libaegisub/log.h +++ b/aegisub/libaegisub/include/libaegisub/log.h @@ -132,7 +132,7 @@ public: /// Destructor ~JsonEmitter(); - void log(SinkMessage *); + void log(SinkMessage *) override; }; /// Generates a message and submits it to the log sink. @@ -149,7 +149,7 @@ public: /// Emit log entries to stdout. class EmitSTDOUT: public Emitter { public: - void log(SinkMessage *sm); + void log(SinkMessage *sm) override; }; } // namespace log diff --git a/aegisub/libaegisub/include/libaegisub/mru.h b/aegisub/libaegisub/include/libaegisub/mru.h index bccb4701c..480a6f435 100644 --- a/aegisub/libaegisub/include/libaegisub/mru.h +++ b/aegisub/libaegisub/include/libaegisub/mru.h @@ -54,7 +54,7 @@ public: /// @brief Constructor /// @param config File to load MRU values from - MRUManager(agi::fs::path const& config, std::string const& default_config, agi::Options *options = 0); + MRUManager(agi::fs::path const& config, std::string const& default_config, agi::Options *options = nullptr); /// Destructor ~MRUManager(); diff --git a/aegisub/libaegisub/include/libaegisub/signal.h b/aegisub/libaegisub/include/libaegisub/signal.h index 0c8aa186f..4067233bc 100644 --- a/aegisub/libaegisub/include/libaegisub/signal.h +++ b/aegisub/libaegisub/include/libaegisub/signal.h @@ -139,7 +139,7 @@ namespace detail { SlotMap slots; /// Signals currently connected to this slot - void Disconnect(ConnectionToken *tok) { + void Disconnect(ConnectionToken *tok) override { slots.erase(tok); } diff --git a/aegisub/libaegisub/include/libaegisub/vfr.h b/aegisub/libaegisub/include/libaegisub/vfr.h index b25ffaf86..29b86e9e1 100644 --- a/aegisub/libaegisub/include/libaegisub/vfr.h +++ b/aegisub/libaegisub/include/libaegisub/vfr.h @@ -107,7 +107,7 @@ public: /// @brief VFR from frame times /// @param timecodes Vector of frame start times in milliseconds - Framerate(std::vector const& timecodes); + Framerate(std::vector timecodes); /// Helper function for the std::swap specialization void swap(Framerate &right) throw(); diff --git a/aegisub/src/aegisublocale.cpp b/aegisub/src/aegisublocale.cpp index 70692e42d..fd801ce8f 100644 --- a/aegisub/src/aegisublocale.cpp +++ b/aegisub/src/aegisublocale.cpp @@ -93,12 +93,12 @@ wxString AegisubLocale::PickLanguage() { // Generate names wxArrayString langNames; - for (size_t i = 0; i < langs.size(); ++i) { - const wxLanguageInfo *info = wxLocale::FindLanguageInfo(langs[i]); + for (auto const& lang : langs) { + const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang); if (info) langNames.push_back(wxLocale::GetLanguageName(info->Language)); else - langNames.push_back(langs[i]); + langNames.push_back(lang); } long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE; @@ -107,7 +107,7 @@ wxString AegisubLocale::PickLanguage() { wxSingleChoiceDialog dialog(nullptr, "Please choose a language:", "Language", langNames, #if wxCHECK_VERSION(2, 9, 4) - (void **)0, + (void **)nullptr, #else 0, #endif diff --git a/aegisub/src/ass_attachment.cpp b/aegisub/src/ass_attachment.cpp index 5704956fc..1ae4535df 100644 --- a/aegisub/src/ass_attachment.cpp +++ b/aegisub/src/ass_attachment.cpp @@ -52,7 +52,7 @@ AssAttachment::AssAttachment(agi::fs::path const& name, AssEntryGroup group) } AssEntry *AssAttachment::Clone() const { - AssAttachment *clone = new AssAttachment(filename, group); + auto clone = new AssAttachment(filename, group); clone->entry_data = entry_data; return clone; } diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index 0594611dc..6c86fe502 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -96,7 +96,7 @@ public: agi::StringRange next_tok() { if (pos.eof()) - throw SubtitleFormatParseError("Failed parsing line: " + std::string(str.begin(), str.end()), 0); + throw SubtitleFormatParseError("Failed parsing line: " + std::string(str.begin(), str.end()), nullptr); return *pos++; } @@ -115,7 +115,7 @@ void AssDialogue::Parse(std::string const& raw) { str = agi::StringRange(raw.begin() + 9, raw.end()); } else - throw SubtitleFormatParseError("Failed parsing line: " + raw, 0); + throw SubtitleFormatParseError("Failed parsing line: " + raw, nullptr); tokenizer tkn(str); @@ -169,8 +169,8 @@ std::string AssDialogue::GetData(bool ssa) const { append_str(str, End.GetAssFormated()); append_unsafe_str(str, Style); append_unsafe_str(str, Actor); - for (int i = 0; i < 3; ++i) - append_int(str, Margin[i]); + for (auto margin : Margin) + append_int(str, margin); append_unsafe_str(str, Effect); str += Text.get(); @@ -224,7 +224,7 @@ std::auto_ptr> AssDialogue::ParseTags() cons } else { // Create block - AssDialogueBlockOverride *block = new AssDialogueBlockOverride(work); + auto block = new AssDialogueBlockOverride(work); block->ParseTags(); Blocks.push_back(block); @@ -282,7 +282,7 @@ std::string AssDialogue::GetStrippedText() const { } AssEntry *AssDialogue::Clone() const { - AssDialogue *clone = new AssDialogue(*this); + auto clone = new AssDialogue(*this); *const_cast(&clone->Id) = Id; return clone; } diff --git a/aegisub/src/ass_dialogue.h b/aegisub/src/ass_dialogue.h index e3b085640..530dae808 100644 --- a/aegisub/src/ass_dialogue.h +++ b/aegisub/src/ass_dialogue.h @@ -75,7 +75,7 @@ protected: /// Text of this block std::string text; public: - AssDialogueBlock(std::string const& text) : text(text) { } + AssDialogueBlock(std::string text) : text(std::move(text)) { } virtual ~AssDialogueBlock() { } virtual AssBlockType GetType() const = 0; @@ -174,7 +174,7 @@ public: /// Does this line collide with the passed line? bool CollidesWith(const AssDialogue *target) const; - AssEntry *Clone() const; + AssEntry *Clone() const override; AssDialogue(); AssDialogue(AssDialogue const&); diff --git a/aegisub/src/ass_export_filter.cpp b/aegisub/src/ass_export_filter.cpp index 11f09c44f..7bb31a1e8 100644 --- a/aegisub/src/ass_export_filter.cpp +++ b/aegisub/src/ass_export_filter.cpp @@ -43,10 +43,10 @@ static FilterList& filters() { return instance; } -AssExportFilter::AssExportFilter(std::string const& name, std::string const& description, int priority) -: name(name) +AssExportFilter::AssExportFilter(std::string name, std::string description, int priority) +: name(std::move(name)) , priority(priority) -, description(description) +, description(std::move(description)) { } diff --git a/aegisub/src/ass_export_filter.h b/aegisub/src/ass_export_filter.h index 12daa3cf1..42b9b1f78 100644 --- a/aegisub/src/ass_export_filter.h +++ b/aegisub/src/ass_export_filter.h @@ -59,7 +59,7 @@ class AssExportFilter : public boost::intrusive::make_list_base_hook const& lines, agi::Context *c bool in_sel = sel.count(diag) > 0; for (auto const& syl : kara) { - AssDialogue *new_line = new AssDialogue(*diag); + auto new_line = new AssDialogue(*diag); new_line->Start = syl.start_time; new_line->End = syl.start_time + syl.duration; diff --git a/aegisub/src/ass_karaoke.h b/aegisub/src/ass_karaoke.h index daf537c85..2ff8161d4 100644 --- a/aegisub/src/ass_karaoke.h +++ b/aegisub/src/ass_karaoke.h @@ -60,7 +60,7 @@ public: /// @param line Initial line /// @param auto_split Should the line automatically be split on spaces if there are no k tags? /// @param normalize Should the total duration of the syllables be forced to equal the line duration? - AssKaraoke(AssDialogue *line = 0, bool auto_split = false, bool normalize = true); + AssKaraoke(AssDialogue *line = nullptr, bool auto_split = false, bool normalize = true); /// Parse a dialogue line void SetLine(AssDialogue *line, bool auto_split = false, bool normalize = true); diff --git a/aegisub/src/ass_override.cpp b/aegisub/src/ass_override.cpp index 89b50f0dd..d6a0fe85a 100644 --- a/aegisub/src/ass_override.cpp +++ b/aegisub/src/ass_override.cpp @@ -79,7 +79,7 @@ AssOverrideParameter::~AssOverrideParameter() { } template<> std::string AssOverrideParameter::Get() const { - if (omitted) throw agi::InternalError("AssOverrideParameter::Get() called on omitted parameter", 0); + if (omitted) throw agi::InternalError("AssOverrideParameter::Get() called on omitted parameter", nullptr); if (block.get()) { std::string str(block->GetText()); if (boost::starts_with(str, "{")) str.erase(begin(str)); diff --git a/aegisub/src/ass_parser.cpp b/aegisub/src/ass_parser.cpp index b2ff4125d..16d18f411 100644 --- a/aegisub/src/ass_parser.cpp +++ b/aegisub/src/ass_parser.cpp @@ -81,7 +81,7 @@ void AssParser::ParseScriptInfoLine(std::string const& data) { else if (version_str == "v4.00+") version = 1; else - throw SubtitleFormatParseError("Unknown SSA file format version", 0); + throw SubtitleFormatParseError("Unknown SSA file format version", nullptr); } // Nothing actually supports the Collisions property and malformed values diff --git a/aegisub/src/ass_style.cpp b/aegisub/src/ass_style.cpp index 843a86487..9781d927c 100644 --- a/aegisub/src/ass_style.cpp +++ b/aegisub/src/ass_style.cpp @@ -80,7 +80,7 @@ class parser { std::string next_tok() { if (pos.eof()) - throw SubtitleFormatParseError("Malformed style: not enough fields", 0); + throw SubtitleFormatParseError("Malformed style: not enough fields", nullptr); return agi::str(trim_copy(*pos++)); } @@ -93,7 +93,7 @@ public: void check_done() const { if (!pos.eof()) - throw SubtitleFormatParseError("Malformed style: too many fields", 0); + throw SubtitleFormatParseError("Malformed style: too many fields", nullptr); } std::string next_str() { return next_tok(); } @@ -104,7 +104,7 @@ public: return boost::lexical_cast(next_tok()); } catch (boost::bad_lexical_cast const&) { - throw SubtitleFormatParseError("Malformed style: bad int field", 0); + throw SubtitleFormatParseError("Malformed style: bad int field", nullptr); } } @@ -113,7 +113,7 @@ public: return boost::lexical_cast(next_tok()); } catch (boost::bad_lexical_cast const&) { - throw SubtitleFormatParseError("Malformed style: bad double field", 0); + throw SubtitleFormatParseError("Malformed style: bad double field", nullptr); } } diff --git a/aegisub/src/ass_style_storage.cpp b/aegisub/src/ass_style_storage.cpp index 857bbca8d..2d6aea5c8 100644 --- a/aegisub/src/ass_style_storage.cpp +++ b/aegisub/src/ass_style_storage.cpp @@ -97,5 +97,5 @@ AssStyle *AssStyleStorage::GetStyle(std::string const& name) { if (boost::iequals(cur->name, name)) return cur.get(); } - return 0; + return nullptr; } diff --git a/aegisub/src/ass_time.cpp b/aegisub/src/ass_time.cpp index 88328a39f..589ceef25 100644 --- a/aegisub/src/ass_time.cpp +++ b/aegisub/src/ass_time.cpp @@ -89,9 +89,9 @@ int AssTime::GetTimeSeconds() const { return (time % 60000) / 1000; } int AssTime::GetTimeMiliseconds() const { return (time % 1000); } int AssTime::GetTimeCentiseconds() const { return (time % 1000) / 10; } -SmpteFormatter::SmpteFormatter(agi::vfr::Framerate fps, std::string const& sep) -: fps(fps) -, sep(sep) +SmpteFormatter::SmpteFormatter(agi::vfr::Framerate fps, std::string sep) +: fps(std::move(fps)) +, sep(std::move(sep)) { } diff --git a/aegisub/src/ass_time.h b/aegisub/src/ass_time.h index 54d29ba76..6210df06a 100644 --- a/aegisub/src/ass_time.h +++ b/aegisub/src/ass_time.h @@ -56,7 +56,7 @@ class SmpteFormatter { std::string sep; public: - SmpteFormatter(agi::vfr::Framerate fps, std::string const& sep=":"); + SmpteFormatter(agi::vfr::Framerate fps, std::string sep=":"); /// Convert an AssTime to a SMPTE timecode std::string ToSMPTE(AssTime time) const; diff --git a/aegisub/src/audio_box.cpp b/aegisub/src/audio_box.cpp index 021d0c550..57b9ae3ef 100644 --- a/aegisub/src/audio_box.cpp +++ b/aegisub/src/audio_box.cpp @@ -105,7 +105,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context) wxSizer *VertVolArea = new wxBoxSizer(wxVERTICAL); VertVolArea->Add(VertVol,1,wxEXPAND,0); - ToggleBitmap *link_btn = new ToggleBitmap(panel, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1)); + auto link_btn = new ToggleBitmap(panel, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1)); link_btn->SetMaxSize(wxDefaultSize); VertVolArea->Add(link_btn, 0, wxRIGHT | wxALIGN_CENTER | wxEXPAND, 0); OPT_SUB("Audio/Link", &AudioBox::OnVerticalLink, this); @@ -119,7 +119,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context) context->karaoke = new AudioKaraoke(panel, context); // Main sizer - wxBoxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); + auto MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3); MainSizer->Add(toolbar::GetToolbar(panel, "audio", context, "Audio"),0,wxEXPAND|wxLEFT|wxRIGHT,3); MainSizer->Add(context->karaoke,0,wxEXPAND|wxALL,3); diff --git a/aegisub/src/audio_colorscheme.cpp b/aegisub/src/audio_colorscheme.cpp index c0666793d..007c951b1 100644 --- a/aegisub/src/audio_colorscheme.cpp +++ b/aegisub/src/audio_colorscheme.cpp @@ -55,7 +55,7 @@ AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int case AudioStyle_Inactive: opt_base += "Inactive/"; break; case AudioStyle_Selected: opt_base += "Selection/"; break; case AudioStyle_Primary: opt_base += "Primary/"; break; - default: throw agi::InternalError("Unknown audio rendering styling", 0); + default: throw agi::InternalError("Unknown audio rendering styling", nullptr); } double h_base = OPT_GET(opt_base + "Hue Offset")->GetDouble(); diff --git a/aegisub/src/audio_controller.cpp b/aegisub/src/audio_controller.cpp index 6c5658783..b56b1f9c7 100644 --- a/aegisub/src/audio_controller.cpp +++ b/aegisub/src/audio_controller.cpp @@ -155,7 +155,7 @@ void AudioController::OnAudioProviderChanged() void AudioController::OpenAudio(agi::fs::path const& url) { if (url.empty()) - throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", 0); + throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", nullptr); std::unique_ptr new_provider; try { @@ -204,8 +204,8 @@ void AudioController::CloseAudio() player.reset(); provider.reset(); - player = 0; - provider = 0; + player = nullptr; + provider = nullptr; audio_url.clear(); diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index 86f1637de..197ec722e 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -199,7 +199,7 @@ public: RecalculateThumb(); } - bool OnMouseEvent(wxMouseEvent &event) + bool OnMouseEvent(wxMouseEvent &event) override { if (event.LeftIsDown()) { @@ -357,7 +357,7 @@ public: pixel_left = std::max(new_pixel_left, 0); } - bool OnMouseEvent(wxMouseEvent &event) + bool OnMouseEvent(wxMouseEvent &event) override { if (event.LeftDown()) { @@ -475,7 +475,7 @@ class AudioMarkerInteractionObject : public AudioDisplayInteractionObject { public: AudioMarkerInteractionObject(std::vector markers, AudioTimingController *timing_controller, AudioDisplay *display, wxMouseButton button_used) - : markers(markers) + : markers(std::move(markers)) , timing_controller(timing_controller) , display(display) , button_used(button_used) @@ -484,7 +484,7 @@ public: { } - bool OnMouseEvent(wxMouseEvent &event) + bool OnMouseEvent(wxMouseEvent &event) override { if (event.Dragging()) { @@ -512,7 +512,7 @@ private: void Split(int point) { - iterator it = points.lower_bound(point); + auto it = points.lower_bound(point); if (it == points.end() || it->first != point) { assert(it != points.begin()); @@ -523,7 +523,7 @@ private: void Restyle(int start, int end, AudioRenderingStyle style) { assert(points.lower_bound(end) != points.end()); - for (iterator pt = points.lower_bound(start); pt->first < end; ++pt) + for (auto pt = points.lower_bound(start); pt->first < end; ++pt) { if (style > pt->second) pt->second = style; @@ -536,7 +536,7 @@ public: points[0] = AudioStyle_Normal; } - void AddRange(int start, int end, AudioRenderingStyle style) + void AddRange(int start, int end, AudioRenderingStyle style) override { if (start < 0) start = 0; @@ -559,7 +559,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C , controller(controller) , scrollbar(agi::util::make_unique(this)) , timeline(agi::util::make_unique(this)) -, dragged_object(0) +, dragged_object(nullptr) , scroll_left(0) , pixel_audio_width(0) , ms_per_pixel(0.0) @@ -1078,7 +1078,7 @@ bool AudioDisplay::ForwardMouseEvent(wxMouseEvent &event) { if (!dragged_object->OnMouseEvent(event)) { scroll_timer.Stop(); - SetDraggedObject(0); + SetDraggedObject(nullptr); SetCursor(wxNullCursor); } return true; @@ -1087,12 +1087,12 @@ bool AudioDisplay::ForwardMouseEvent(wxMouseEvent &event) { { // Something is wrong, we might have lost capture somehow. // Fix state and pretend it didn't happen. - SetDraggedObject(0); + SetDraggedObject(nullptr); SetCursor(wxNullCursor); } const wxPoint mousepos = event.GetPosition(); - AudioDisplayInteractionObject *new_obj = 0; + AudioDisplayInteractionObject *new_obj = nullptr; // Check for scrollbar action if (scrollbar->GetBounds().Contains(mousepos)) { diff --git a/aegisub/src/audio_karaoke.cpp b/aegisub/src/audio_karaoke.cpp index 02a4c10ab..9798a1ebe 100644 --- a/aegisub/src/audio_karaoke.cpp +++ b/aegisub/src/audio_karaoke.cpp @@ -54,7 +54,7 @@ template static inline size_t last_lt_or_eq(Container const& c, Value const& v) { - typename Container::const_iterator it = lower_bound(c.begin(), c.end(), v); + auto it = lower_bound(c.begin(), c.end(), v); // lower_bound gives first >= if (it == c.end() || *it > v) --it; @@ -137,7 +137,7 @@ void AudioKaraoke::OnAudioOpened() { } void AudioKaraoke::OnAudioClosed() { - c->audioController->SetTimingController(0); + c->audioController->SetTimingController(nullptr); } void AudioKaraoke::SetEnabled(bool en) { @@ -236,8 +236,8 @@ void AudioKaraoke::RenderText() { // Draw the lines between each syllable dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - for (size_t i = 0; i < syl_lines.size(); ++i) - dc.DrawLine(syl_lines[i], 0, syl_lines[i], bmp_size.GetHeight()); + for (auto syl_line : syl_lines) + dc.DrawLine(syl_line, 0, syl_line, bmp_size.GetHeight()); } void AudioKaraoke::AddMenuItem(wxMenu &menu, std::string const& tag, wxString const& help, std::string const& selected) { diff --git a/aegisub/src/audio_marker.cpp b/aegisub/src/audio_marker.cpp index eb915c787..6c0e4c7a3 100644 --- a/aegisub/src/audio_marker.cpp +++ b/aegisub/src/audio_marker.cpp @@ -37,10 +37,10 @@ class AudioMarkerKeyframe : public AudioMarker { int position; public: AudioMarkerKeyframe(Pen *style, int position) : style(style), position(position) { } - int GetPosition() const { return position; } - FeetStyle GetFeet() const { return Feet_None; } - bool CanSnap() const { return true; } - wxPen GetStyle() const { return *style; } + int GetPosition() const override { return position; } + FeetStyle GetFeet() const override { return Feet_None; } + bool CanSnap() const override { return true; } + wxPen GetStyle() const override { return *style; } operator int() const { return position; } }; @@ -99,10 +99,10 @@ public: void SetPosition(int new_pos) { position = new_pos; } - int GetPosition() const { return position; } - FeetStyle GetFeet() const { return Feet_None; } - bool CanSnap() const { return true; } - wxPen GetStyle() const { return style; } + int GetPosition() const override { return position; } + FeetStyle GetFeet() const override { return Feet_None; } + bool CanSnap() const override { return true; } + wxPen GetStyle() const override { return style; } operator int() const { return position; } }; diff --git a/aegisub/src/audio_marker.h b/aegisub/src/audio_marker.h index d4ec7fdd0..ca32e603d 100644 --- a/aegisub/src/audio_marker.h +++ b/aegisub/src/audio_marker.h @@ -151,7 +151,7 @@ public: /// Get all keyframe markers within a range /// @param range Time range to get markers for /// @param[out] out Vector to fill with markers in the range - void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const; + void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override; }; /// Marker provider for the current video playback position @@ -170,7 +170,7 @@ public: VideoPositionMarkerProvider(agi::Context *c); ~VideoPositionMarkerProvider(); - void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const; + void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const override; }; /// Marker provider for lines every second @@ -180,10 +180,10 @@ class SecondsMarkerProvider : public AudioMarkerProvider { int position; Marker(Pen *style) : style(style), position(0) { } - int GetPosition() const { return position; } - FeetStyle GetFeet() const { return Feet_None; } - bool CanSnap() const { return false; } - wxPen GetStyle() const; + int GetPosition() const override { return position; } + FeetStyle GetFeet() const override { return Feet_None; } + bool CanSnap() const override { return false; } + wxPen GetStyle() const override; operator int() const { return position; } }; @@ -203,5 +203,5 @@ class SecondsMarkerProvider : public AudioMarkerProvider { public: SecondsMarkerProvider(); - void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const; + void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override; }; diff --git a/aegisub/src/audio_player.cpp b/aegisub/src/audio_player.cpp index 407d5059d..dfe8e8561 100644 --- a/aegisub/src/audio_player.cpp +++ b/aegisub/src/audio_player.cpp @@ -53,7 +53,7 @@ AudioPlayer::AudioPlayer(AudioProvider *provider) std::unique_ptr AudioPlayerFactory::GetAudioPlayer(AudioProvider *provider) { std::vector list = GetClasses(OPT_GET("Audio/Player")->GetString()); - if (list.empty()) throw agi::NoAudioPlayersError("No audio players are available.", 0); + if (list.empty()) throw agi::NoAudioPlayersError("No audio players are available.", nullptr); std::string error; for (auto const& factory_name : list) { @@ -64,7 +64,7 @@ std::unique_ptr AudioPlayerFactory::GetAudioPlayer(AudioProvider *p error += factory_name + " factory: " + err.GetChainedMessage() + "\n"; } } - throw agi::AudioPlayerOpenError(error, 0); + throw agi::AudioPlayerOpenError(error, nullptr); } void AudioPlayerFactory::RegisterProviders() { diff --git a/aegisub/src/audio_player_openal.cpp b/aegisub/src/audio_player_openal.cpp index ef489a657..b9be1c7c3 100644 --- a/aegisub/src/audio_player_openal.cpp +++ b/aegisub/src/audio_player_openal.cpp @@ -59,8 +59,8 @@ OpenALPlayer::OpenALPlayer(AudioProvider *provider) , start_frame(0) , cur_frame(0) , end_frame(0) -, device(0) -, context(0) +, device(nullptr) +, context(nullptr) , source(0) , buf_first_free(0) , buf_first_queued(0) @@ -69,26 +69,26 @@ OpenALPlayer::OpenALPlayer(AudioProvider *provider) { try { // Open device - device = alcOpenDevice(0); - if (!device) throw OpenALException("Failed opening default OpenAL device", 0); + device = alcOpenDevice(nullptr); + if (!device) throw OpenALException("Failed opening default OpenAL device", nullptr); // Create context - context = alcCreateContext(device, 0); - if (!context) throw OpenALException("Failed creating OpenAL context", 0); - if (!alcMakeContextCurrent(context)) throw OpenALException("Failed selecting OpenAL context", 0); + context = alcCreateContext(device, nullptr); + if (!context) throw OpenALException("Failed creating OpenAL context", nullptr); + if (!alcMakeContextCurrent(context)) throw OpenALException("Failed selecting OpenAL context", nullptr); // Clear error code alGetError(); // Generate buffers alGenBuffers(num_buffers, buffers); - if (alGetError() != AL_NO_ERROR) throw OpenALException("Error generating OpenAL buffers", 0); + if (alGetError() != AL_NO_ERROR) throw OpenALException("Error generating OpenAL buffers", nullptr); // Generate source alGenSources(1, &source); if (alGetError() != AL_NO_ERROR) { alDeleteBuffers(num_buffers, buffers); - throw OpenALException("Error generating OpenAL source", 0); + throw OpenALException("Error generating OpenAL source", nullptr); } } catch (...) diff --git a/aegisub/src/audio_player_openal.h b/aegisub/src/audio_player_openal.h index aef6cf29b..ddd822122 100644 --- a/aegisub/src/audio_player_openal.h +++ b/aegisub/src/audio_player_openal.h @@ -92,20 +92,20 @@ class OpenALPlayer : public AudioPlayer, wxTimer { protected: /// wxTimer override to periodically fill available buffers - void Notify(); + void Notify() override; public: OpenALPlayer(AudioProvider *provider); ~OpenALPlayer(); - void Play(int64_t start,int64_t count); - void Stop(); - bool IsPlaying() { return playing; } + void Play(int64_t start,int64_t count) override; + void Stop() override; + bool IsPlaying() override { return playing; } - int64_t GetEndPosition() { return end_frame; } - int64_t GetCurrentPosition(); - void SetEndPosition(int64_t pos); + int64_t GetEndPosition() override { return end_frame; } + int64_t GetCurrentPosition() override; + void SetEndPosition(int64_t pos) override; - void SetVolume(double vol) { volume = vol; } + void SetVolume(double vol) override { volume = vol; } }; #endif diff --git a/aegisub/src/audio_provider.cpp b/aegisub/src/audio_provider.cpp index 4e0928390..820238e1d 100644 --- a/aegisub/src/audio_provider.cpp +++ b/aegisub/src/audio_provider.cpp @@ -59,7 +59,7 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, if (volume == 1.0) return; if (bytes_per_sample != 2) - throw agi::InternalError("GetAudioWithVolume called on unconverted audio stream", 0); + throw agi::InternalError("GetAudioWithVolume called on unconverted audio stream", nullptr); short *buffer = static_cast(buf); for (size_t i = 0; i < (size_t)count; ++i) @@ -159,7 +159,7 @@ std::unique_ptr AudioProviderFactory::GetProvider(agi::fs::path c if (!provider) { std::vector list = GetClasses(OPT_GET("Audio/Provider")->GetString()); - if (list.empty()) throw agi::NoAudioProvidersError("No audio providers are available.", 0); + if (list.empty()) throw agi::NoAudioProvidersError("No audio providers are available.", nullptr); for (auto const& name : list) { provider = creator.try_create(name, [&]() { return Create(name, filename); }); @@ -169,9 +169,9 @@ std::unique_ptr AudioProviderFactory::GetProvider(agi::fs::path c if (!provider) { if (creator.found_audio) - throw agi::AudioProviderOpenError(creator.msg, 0); + throw agi::AudioProviderOpenError(creator.msg, nullptr); if (creator.found_file) - throw agi::AudioDataNotFoundError(creator.msg, 0); + throw agi::AudioDataNotFoundError(creator.msg, nullptr); throw agi::fs::FileNotFound(filename); } @@ -194,7 +194,7 @@ std::unique_ptr AudioProviderFactory::GetProvider(agi::fs::path c // Convert to HD if (cache == 2) return agi::util::make_unique(std::move(provider), &progress); - throw agi::AudioCacheOpenError("Unknown caching method", 0); + throw agi::AudioCacheOpenError("Unknown caching method", nullptr); } void AudioProviderFactory::RegisterProviders() { diff --git a/aegisub/src/audio_provider_convert.cpp b/aegisub/src/audio_provider_convert.cpp index bdc3e9240..6fe1de0e7 100644 --- a/aegisub/src/audio_provider_convert.cpp +++ b/aegisub/src/audio_provider_convert.cpp @@ -38,13 +38,13 @@ class BitdepthConvertAudioProvider : public AudioProviderWrapper { public: BitdepthConvertAudioProvider(std::unique_ptr src) : AudioProviderWrapper(std::move(src)) { if (bytes_per_sample > 8) - throw agi::AudioProviderOpenError("Audio format converter: audio with bitdepths greater than 64 bits/sample is currently unsupported", 0); + throw agi::AudioProviderOpenError("Audio format converter: audio with bitdepths greater than 64 bits/sample is currently unsupported", nullptr); src_bytes_per_sample = bytes_per_sample; bytes_per_sample = sizeof(Target); } - void FillBuffer(void *buf, int64_t start, int64_t count) const { + void FillBuffer(void *buf, int64_t start, int64_t count) const override { std::vector src_buf(count * src_bytes_per_sample * channels); source->GetAudio(&src_buf[0], start, count); @@ -81,7 +81,7 @@ public: float_samples = false; } - void FillBuffer(void *buf, int64_t start, int64_t count) const { + void FillBuffer(void *buf, int64_t start, int64_t count) const override { std::vector src_buf(count * channels); source->GetAudio(&src_buf[0], start, count); @@ -110,14 +110,14 @@ class DownmixAudioProvider : public AudioProviderWrapper { public: DownmixAudioProvider(std::unique_ptr src) : AudioProviderWrapper(std::move(src)) { if (bytes_per_sample != 2) - throw agi::InternalError("DownmixAudioProvider requires 16-bit input", 0); + throw agi::InternalError("DownmixAudioProvider requires 16-bit input", nullptr); if (channels == 1) - throw agi::InternalError("DownmixAudioProvider requires multi-channel input", 0); + throw agi::InternalError("DownmixAudioProvider requires multi-channel input", nullptr); src_channels = channels; channels = 1; } - void FillBuffer(void *buf, int64_t start, int64_t count) const { + void FillBuffer(void *buf, int64_t start, int64_t count) const override { if (count == 0) return; std::vector src_buf(count * src_channels); @@ -140,15 +140,15 @@ class SampleDoublingAudioProvider : public AudioProviderWrapper { public: SampleDoublingAudioProvider(std::unique_ptr src) : AudioProviderWrapper(std::move(src)) { if (source->GetBytesPerSample() != 2) - throw agi::InternalError("UpsampleAudioProvider requires 16-bit input", 0); + throw agi::InternalError("UpsampleAudioProvider requires 16-bit input", nullptr); if (source->GetChannels() != 1) - throw agi::InternalError("UpsampleAudioProvider requires mono input", 0); + throw agi::InternalError("UpsampleAudioProvider requires mono input", nullptr); sample_rate *= 2; num_samples *= 2; } - void FillBuffer(void *buf, int64_t start, int64_t count) const { + void FillBuffer(void *buf, int64_t start, int64_t count) const override { if (count == 0) return; int not_end = start + count < num_samples; diff --git a/aegisub/src/audio_provider_dummy.h b/aegisub/src/audio_provider_dummy.h index f083c9728..e63584a60 100644 --- a/aegisub/src/audio_provider_dummy.h +++ b/aegisub/src/audio_provider_dummy.h @@ -36,7 +36,7 @@ class DummyAudioProvider : public AudioProvider { bool noise; - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; public: DummyAudioProvider(agi::fs::path const& uri); diff --git a/aegisub/src/audio_provider_ffmpegsource.cpp b/aegisub/src/audio_provider_ffmpegsource.cpp index 203110a03..534d49c84 100644 --- a/aegisub/src/audio_provider_ffmpegsource.cpp +++ b/aegisub/src/audio_provider_ffmpegsource.cpp @@ -58,10 +58,10 @@ FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(agi::fs::path const& filena LoadAudio(filename); } catch (std::string const& err) { - throw agi::AudioProviderOpenError(err, 0); + throw agi::AudioProviderOpenError(err, nullptr); } catch (const char *err) { - throw agi::AudioProviderOpenError(err, 0); + throw agi::AudioProviderOpenError(err, nullptr); } void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { @@ -70,12 +70,12 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { if (ErrInfo.SubType == FFMS_ERROR_FILE_READ) throw agi::fs::FileNotFound(std::string(ErrInfo.Buffer)); else - throw agi::AudioDataNotFoundError(ErrInfo.Buffer, 0); + throw agi::AudioDataNotFoundError(ErrInfo.Buffer, nullptr); } std::map TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO); if (TrackList.empty()) - throw agi::AudioDataNotFoundError("no audio tracks found", 0); + throw agi::AudioDataNotFoundError("no audio tracks found", nullptr); // initialize the track number to an invalid value so we can detect later on // whether the user actually had to choose a track or not @@ -103,7 +103,7 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { if (TrackNumber < 0) TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo); if (TrackNumber < 0) - throw agi::AudioDataNotFoundError(std::string("Couldn't find any audio tracks: ") + ErrInfo.Buffer, 0); + throw agi::AudioDataNotFoundError(std::string("Couldn't find any audio tracks: ") + ErrInfo.Buffer, nullptr); // index is valid and track number is now set, // but do we have indexing info for the desired audio track? @@ -145,7 +145,7 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { AudioSource = FFMS_CreateAudioSource(filename.string().c_str(), TrackNumber, Index, -1, &ErrInfo); if (!AudioSource) - throw agi::AudioProviderOpenError(std::string("Failed to open audio track: ") + ErrInfo.Buffer, 0); + throw agi::AudioProviderOpenError(std::string("Failed to open audio track: ") + ErrInfo.Buffer, nullptr); const FFMS_AudioProperties AudioInfo = *FFMS_GetAudioProperties(AudioSource); @@ -153,7 +153,7 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { sample_rate = AudioInfo.SampleRate; num_samples = AudioInfo.NumSamples; if (channels <= 0 || sample_rate <= 0 || num_samples <= 0) - throw agi::AudioProviderOpenError("sanity check failed, consult your local psychiatrist", 0); + throw agi::AudioProviderOpenError("sanity check failed, consult your local psychiatrist", nullptr); switch (AudioInfo.SampleFormat) { case FFMS_FMT_U8: bytes_per_sample = 1; float_samples = false; break; @@ -162,7 +162,7 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) { case FFMS_FMT_FLT: bytes_per_sample = 4; float_samples = true; break; case FFMS_FMT_DBL: bytes_per_sample = 8; float_samples = true; break; default: - throw agi::AudioProviderOpenError("unknown or unsupported sample format", 0); + throw agi::AudioProviderOpenError("unknown or unsupported sample format", nullptr); } #if FFMS_VERSION >= ((2 << 24) | (17 << 16) | (4 << 8) | 0) diff --git a/aegisub/src/audio_provider_ffmpegsource.h b/aegisub/src/audio_provider_ffmpegsource.h index 7d1cb0447..0946af7ea 100644 --- a/aegisub/src/audio_provider_ffmpegsource.h +++ b/aegisub/src/audio_provider_ffmpegsource.h @@ -47,11 +47,11 @@ class FFmpegSourceAudioProvider : public AudioProvider, FFmpegSourceProvider { mutable FFMS_ErrorInfo ErrInfo; ///< FFMS error codes/messages void LoadAudio(agi::fs::path const& filename); - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; public: FFmpegSourceAudioProvider(agi::fs::path const& filename); - bool NeedsCache() const { return true; } + bool NeedsCache() const override { return true; } }; #endif diff --git a/aegisub/src/audio_provider_hd.cpp b/aegisub/src/audio_provider_hd.cpp index f0153e8de..235067fd4 100644 --- a/aegisub/src/audio_provider_hd.cpp +++ b/aegisub/src/audio_provider_hd.cpp @@ -95,7 +95,7 @@ HDAudioProvider::HDAudioProvider(std::unique_ptr src, agi::Backgr { // Check free space if ((uint64_t)num_samples * channels * bytes_per_sample > agi::fs::FreeSpace(cache_dir())) - throw agi::AudioCacheOpenError("Not enough free disk space in " + cache_dir().string() + " to cache the audio", 0); + throw agi::AudioCacheOpenError("Not enough free disk space in " + cache_dir().string() + " to cache the audio", nullptr); diskCacheFilename = cache_path(); diff --git a/aegisub/src/audio_provider_hd.h b/aegisub/src/audio_provider_hd.h index abb32c309..b36b8f67a 100644 --- a/aegisub/src/audio_provider_hd.h +++ b/aegisub/src/audio_provider_hd.h @@ -51,7 +51,7 @@ class HDAudioProvider : public AudioProviderWrapper { /// @param ps Sink for progress reporting void FillCache(AudioProvider *src, std::ofstream *file, agi::ProgressSink *ps); - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; public: HDAudioProvider(std::unique_ptr source, agi::BackgroundRunner *br); diff --git a/aegisub/src/audio_provider_lock.h b/aegisub/src/audio_provider_lock.h index 75f012b14..37f8c5c3a 100644 --- a/aegisub/src/audio_provider_lock.h +++ b/aegisub/src/audio_provider_lock.h @@ -24,7 +24,7 @@ class LockAudioProvider : public AudioProviderWrapper { mutable std::mutex mutex; - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; public: LockAudioProvider(std::unique_ptr source); }; diff --git a/aegisub/src/audio_provider_pcm.cpp b/aegisub/src/audio_provider_pcm.cpp index 07e955cc3..f45fec3c6 100644 --- a/aegisub/src/audio_provider_pcm.cpp +++ b/aegisub/src/audio_provider_pcm.cpp @@ -52,7 +52,7 @@ #endif PCMAudioProvider::PCMAudioProvider(agi::fs::path const& filename) -: current_mapping(0) +: current_mapping(nullptr) , mapping_start(0) , mapping_length(0) #ifdef _WIN32 @@ -154,7 +154,7 @@ char * PCMAudioProvider::EnsureRangeAccessible(int64_t range_start, int64_t rang mapping_start_li.LowPart, // Offset low-part mapping_length); // Length of view #else - current_mapping = mmap(0, mapping_length, PROT_READ, MAP_PRIVATE, file_handle, mapping_start); + current_mapping = mmap(nullptr, mapping_length, PROT_READ, MAP_PRIVATE, file_handle, mapping_start); #endif if (!current_mapping) @@ -263,9 +263,9 @@ public: // Check magic values if (!CheckFourcc(header.ch.type, "RIFF")) - throw agi::AudioDataNotFoundError("File is not a RIFF file", 0); + throw agi::AudioDataNotFoundError("File is not a RIFF file", nullptr); if (!CheckFourcc(header.format, "WAVE")) - throw agi::AudioDataNotFoundError("File is not a RIFF WAV file", 0); + throw agi::AudioDataNotFoundError("File is not a RIFF WAV file", nullptr); // Count how much more data we can have in the entire file // The first 4 bytes are already eaten by the header.format field @@ -288,13 +288,13 @@ public: filepos += sizeof(ch); if (CheckFourcc(ch.type, "fmt ")) { - if (got_fmt_header) throw agi::AudioProviderOpenError("Invalid file, multiple 'fmt ' chunks", 0); + if (got_fmt_header) throw agi::AudioProviderOpenError("Invalid file, multiple 'fmt ' chunks", nullptr); got_fmt_header = true; fmtChunk &fmt = *(fmtChunk*)EnsureRangeAccessible(filepos, sizeof(fmtChunk)); if (fmt.compression != 1) - throw agi::AudioProviderOpenError("Can't use file, not PCM encoding", 0); + throw agi::AudioProviderOpenError("Can't use file, not PCM encoding", nullptr); // Set stuff inherited from the AudioProvider class sample_rate = fmt.samplerate; @@ -306,7 +306,7 @@ public: // This won't pick up 'data' chunks inside 'wavl' chunks // since the 'wavl' chunks wrap those. - if (!got_fmt_header) throw agi::AudioProviderOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.", 0); + if (!got_fmt_header) throw agi::AudioProviderOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.", nullptr); int64_t samples = ch.size / bytes_per_sample; int64_t frames = samples / channels; @@ -400,7 +400,7 @@ public: int64_t smallest_possible_file = sizeof(RiffChunk) + sizeof(FormatChunk) + sizeof(DataChunk); if (file_size < smallest_possible_file) - throw agi::AudioDataNotFoundError("File is too small to be a Wave64 file", 0); + throw agi::AudioDataNotFoundError("File is too small to be a Wave64 file", nullptr); // Read header // This should throw an exception if the mapping fails @@ -410,9 +410,9 @@ public: // Check magic values if (!CheckGuid(header.riff_guid, w64GuidRIFF)) - throw agi::AudioDataNotFoundError("File is not a Wave64 RIFF file", 0); + throw agi::AudioDataNotFoundError("File is not a Wave64 RIFF file", nullptr); if (!CheckGuid(header.format_guid, w64GuidWAVE)) - throw agi::AudioDataNotFoundError("File is not a Wave64 WAVE file", 0); + throw agi::AudioDataNotFoundError("File is not a Wave64 WAVE file", nullptr); // Count how much more data we can have in the entire file uint64_t data_left = header.file_size - sizeof(RiffChunk); @@ -432,15 +432,15 @@ public: if (CheckGuid(chunk_guid, w64Guidfmt)) { if (got_fmt_header) - throw agi::AudioProviderOpenError("Bad file, found more than one 'fmt' chunk", 0); + throw agi::AudioProviderOpenError("Bad file, found more than one 'fmt' chunk", nullptr); FormatChunk &fmt = *(FormatChunk*)EnsureRangeAccessible(filepos, sizeof(FormatChunk)); got_fmt_header = true; if (fmt.format.wFormatTag == 3) - throw agi::AudioProviderOpenError("File is IEEE 32 bit float format which isn't supported. Bug the developers if this matters.", 0); + throw agi::AudioProviderOpenError("File is IEEE 32 bit float format which isn't supported. Bug the developers if this matters.", nullptr); if (fmt.format.wFormatTag != 1) - throw agi::AudioProviderOpenError("Can't use file, not PCM encoding", 0); + throw agi::AudioProviderOpenError("Can't use file, not PCM encoding", nullptr); // Set stuff inherited from the AudioProvider class sample_rate = fmt.format.nSamplesPerSec; @@ -449,7 +449,7 @@ public: } else if (CheckGuid(chunk_guid, w64Guiddata)) { if (!got_fmt_header) - throw agi::AudioProviderOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.", 0); + throw agi::AudioProviderOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.", nullptr); int64_t samples = chunk_size / bytes_per_sample; int64_t frames = samples / channels; @@ -498,7 +498,7 @@ std::unique_ptr CreatePCMAudioProvider(agi::fs::path const& filen } if (wrong_file_type) - throw agi::AudioDataNotFoundError(msg, 0); + throw agi::AudioDataNotFoundError(msg, nullptr); else - throw agi::AudioProviderOpenError(msg, 0); + throw agi::AudioProviderOpenError(msg, nullptr); } diff --git a/aegisub/src/audio_provider_pcm.h b/aegisub/src/audio_provider_pcm.h index 50b1ce613..3025f3ebd 100644 --- a/aegisub/src/audio_provider_pcm.h +++ b/aegisub/src/audio_provider_pcm.h @@ -77,7 +77,7 @@ protected: IndexVector index_points; - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; }; // Construct the right PCM audio provider (if any) for the file diff --git a/aegisub/src/audio_provider_ram.cpp b/aegisub/src/audio_provider_ram.cpp index c8cdd69d9..fe88c1bf9 100644 --- a/aegisub/src/audio_provider_ram.cpp +++ b/aegisub/src/audio_provider_ram.cpp @@ -53,7 +53,7 @@ RAMAudioProvider::RAMAudioProvider(std::unique_ptr src, agi::Back blockcache.resize((source->GetNumSamples() * source->GetBytesPerSample() + CacheBlockSize - 1) >> CacheBits); } catch (std::bad_alloc const&) { - throw agi::AudioCacheOpenError("Couldn't open audio, not enough ram available.", 0); + throw agi::AudioCacheOpenError("Couldn't open audio, not enough ram available.", nullptr); } br->Run(std::bind(&RAMAudioProvider::FillCache, this, source.get(), std::placeholders::_1)); diff --git a/aegisub/src/audio_provider_ram.h b/aegisub/src/audio_provider_ram.h index feb392c27..8891951bc 100644 --- a/aegisub/src/audio_provider_ram.h +++ b/aegisub/src/audio_provider_ram.h @@ -50,7 +50,7 @@ class RAMAudioProvider : public AudioProviderWrapper { #endif void FillCache(AudioProvider *source, agi::ProgressSink *ps); - void FillBuffer(void *buf, int64_t start, int64_t count) const; + void FillBuffer(void *buf, int64_t start, int64_t count) const override; public: RAMAudioProvider(std::unique_ptr source, agi::BackgroundRunner *br); diff --git a/aegisub/src/audio_renderer.cpp b/aegisub/src/audio_renderer.cpp index d245ee509..94b486b65 100644 --- a/aegisub/src/audio_renderer.cpp +++ b/aegisub/src/audio_renderer.cpp @@ -71,8 +71,8 @@ AudioRenderer::AudioRenderer() , cache_bitmap_width(32) // arbitrary value for now , cache_bitmap_maxsize(0) , cache_renderer_maxsize(0) -, renderer(0) -, provider(0) +, renderer(nullptr) +, provider(nullptr) { for (int i = 0; i < AudioStyle_MAX; ++i) bitmaps.emplace_back(256, AudioRendererBitmapCacheBitmapFactory(this)); diff --git a/aegisub/src/audio_renderer.h b/aegisub/src/audio_renderer.h index ab6e87b7e..7ab7ef9f4 100644 --- a/aegisub/src/audio_renderer.h +++ b/aegisub/src/audio_renderer.h @@ -254,7 +254,7 @@ protected: public: /// @brief Constructor - AudioRendererBitmapProvider() : provider(0), pixel_ms(0), amplitude_scale(0) { }; + AudioRendererBitmapProvider() : provider(nullptr), pixel_ms(0), amplitude_scale(0) { }; /// @brief Destructor virtual ~AudioRendererBitmapProvider() { } diff --git a/aegisub/src/audio_renderer_spectrum.cpp b/aegisub/src/audio_renderer_spectrum.cpp index ad9e395f7..d16b92e1a 100644 --- a/aegisub/src/audio_renderer_spectrum.cpp +++ b/aegisub/src/audio_renderer_spectrum.cpp @@ -70,7 +70,7 @@ struct AudioSpectrumCacheBlockFactory { /// The filling is delegated to the spectrum renderer BlockType ProduceBlock(size_t i) { - float *res = new float[((size_t)1)<derivation_size]; + auto res = new float[((size_t)1)<derivation_size]; spectrum->FillBlock(i, res); return BlockType(res); } @@ -100,9 +100,9 @@ AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_nam : derivation_size(8) , derivation_dist(8) #ifdef WITH_FFTW3 -, dft_plan(0) -, dft_input(0) -, dft_output(0) +, dft_plan(nullptr) +, dft_input(nullptr) +, dft_output(nullptr) #endif { colors.reserve(AudioStyle_MAX); @@ -125,9 +125,9 @@ void AudioSpectrumRenderer::RecreateCache() fftw_destroy_plan(dft_plan); fftw_free(dft_input); fftw_free(dft_output); - dft_plan = 0; - dft_input = 0; - dft_output = 0; + dft_plan = nullptr; + dft_input = nullptr; + dft_output = nullptr; } #endif diff --git a/aegisub/src/audio_renderer_spectrum.h b/aegisub/src/audio_renderer_spectrum.h index 0b2651ecd..f66c9b182 100644 --- a/aegisub/src/audio_renderer_spectrum.h +++ b/aegisub/src/audio_renderer_spectrum.h @@ -71,7 +71,7 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider { /// /// Overrides the OnSetProvider event handler in the base class, to reset things /// when the audio provider is changed. - void OnSetProvider(); + void OnSetProvider() override; /// @brief Recreates the cache /// @@ -117,10 +117,10 @@ public: /// @param bmp [in,out] Bitmap to render into, also carries length information /// @param start First column of pixel data in display to render /// @param style Style to render audio in - void Render(wxBitmap &bmp, int start, AudioRenderingStyle style); + void Render(wxBitmap &bmp, int start, AudioRenderingStyle style) override; /// @brief Render blank area - void RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style); + void RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style) override; /// @brief Set the derivation resolution /// @param derivation_size Binary logarithm of number of samples to use in deriving frequency-power data @@ -135,5 +135,5 @@ public: /// @brief Cleans up the cache /// @param max_size Maximum size in bytes for the cache - void AgeCache(size_t max_size); + void AgeCache(size_t max_size) override; }; diff --git a/aegisub/src/audio_renderer_waveform.cpp b/aegisub/src/audio_renderer_waveform.cpp index 103970d97..6bafa6e46 100644 --- a/aegisub/src/audio_renderer_waveform.cpp +++ b/aegisub/src/audio_renderer_waveform.cpp @@ -55,7 +55,7 @@ enum { }; AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name) -: audio_buffer(0) +: audio_buffer(nullptr) , render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg) { colors.reserve(AudioStyle_MAX); @@ -168,13 +168,13 @@ void AudioWaveformRenderer::RenderBlank(wxDC &dc, const wxRect &rect, AudioRende void AudioWaveformRenderer::OnSetProvider() { delete[] audio_buffer; - audio_buffer = 0; + audio_buffer = nullptr; } void AudioWaveformRenderer::OnSetMillisecondsPerPixel() { delete[] audio_buffer; - audio_buffer = 0; + audio_buffer = nullptr; } wxArrayString AudioWaveformRenderer::GetWaveformStyles() { diff --git a/aegisub/src/audio_renderer_waveform.h b/aegisub/src/audio_renderer_waveform.h index 9c0f0b575..3fdd7a690 100644 --- a/aegisub/src/audio_renderer_waveform.h +++ b/aegisub/src/audio_renderer_waveform.h @@ -50,8 +50,8 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider { /// Whether to render max+avg or just max bool render_averages; - void OnSetProvider(); - void OnSetMillisecondsPerPixel(); + void OnSetProvider() override; + void OnSetMillisecondsPerPixel() override; public: /// @brief Constructor @@ -65,16 +65,16 @@ public: /// @param bmp [in,out] Bitmap to render into, also carries length information /// @param start First column of pixel data in display to render /// @param style Style to render audio in - void Render(wxBitmap &bmp, int start, AudioRenderingStyle style); + void Render(wxBitmap &bmp, int start, AudioRenderingStyle style) override; /// @brief Render blank area - void RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style); + void RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style) override; /// @brief Cleans up the cache /// @param max_size Maximum size in bytes for the cache /// /// Does nothing for waveform renderer, since it does not have a backend cache - void AgeCache(size_t max_size) { } + void AgeCache(size_t max_size) override { } /// Get a list of waveform rendering modes static wxArrayString GetWaveformStyles(); diff --git a/aegisub/src/audio_timing_dialogue.cpp b/aegisub/src/audio_timing_dialogue.cpp index e68ac2bff..2fbe773e1 100644 --- a/aegisub/src/audio_timing_dialogue.cpp +++ b/aegisub/src/audio_timing_dialogue.cpp @@ -71,10 +71,10 @@ class DialogueTimingMarker : public AudioMarker { TimeableLine *line; public: - int GetPosition() const { return position; } - wxPen GetStyle() const { return *style; } - FeetStyle GetFeet() const { return feet; } - bool CanSnap() const { return true; } + int GetPosition() const override { return position; } + wxPen GetStyle() const override { return *style; } + FeetStyle GetFeet() const override { return feet; } + bool CanSnap() const override { return true; } /// Move the marker to a new position /// @param new_position The position to move the marker to, in milliseconds @@ -179,7 +179,7 @@ public: /// @param style_left The rendering style for the start marker /// @param style_right The rendering style for the end marker TimeableLine(AudioRenderingStyle style, const Pen *style_left, const Pen *style_right) - : line(0) + : line(nullptr) , style(style) , marker1(0, style_left, AudioMarker::Feet_Right, style, this) , marker2(0, style_right, AudioMarker::Feet_Left, style, this) @@ -382,27 +382,27 @@ class AudioTimingControllerDialogue : public AudioTimingController { public: // AudioMarkerProvider interface - void GetMarkers(const TimeRange &range, AudioMarkerVector &out_markers) const; + void GetMarkers(const TimeRange &range, AudioMarkerVector &out_markers) const override; // AudioTimingController interface - wxString GetWarningMessage() const; - TimeRange GetIdealVisibleTimeRange() const; - TimeRange GetPrimaryPlaybackRange() const; - TimeRange GetActiveLineRange() const; - void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const; - void GetLabels(TimeRange const& range, std::vector &out) const { } - void Next(NextMode mode); - void Prev(); - void Commit(); - void Revert(); - void AddLeadIn(); - void AddLeadOut(); - void ModifyLength(int delta, bool shift_following); - void ModifyStart(int delta); - bool IsNearbyMarker(int ms, int sensitivity) const; - std::vector OnLeftClick(int ms, bool ctrl_down, int sensitivity, int snap_range); - std::vector OnRightClick(int ms, bool, int sensitivity, int snap_range); - void OnMarkerDrag(std::vector const& markers, int new_position, int snap_range); + wxString GetWarningMessage() const override; + TimeRange GetIdealVisibleTimeRange() const override; + TimeRange GetPrimaryPlaybackRange() const override; + TimeRange GetActiveLineRange() const override; + void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const override; + void GetLabels(TimeRange const& range, std::vector &out) const override { } + void Next(NextMode mode) override; + void Prev() override; + void Commit() override; + void Revert() override; + void AddLeadIn() override; + void AddLeadOut() override; + void ModifyLength(int delta, bool shift_following) override; + void ModifyStart(int delta) override; + bool IsNearbyMarker(int ms, int sensitivity) const override; + std::vector OnLeftClick(int ms, bool ctrl_down, int sensitivity, int snap_range) override; + std::vector OnRightClick(int ms, bool, int sensitivity, int snap_range) override; + void OnMarkerDrag(std::vector const& markers, int new_position, int snap_range) override; /// Constructor /// @param c Project context @@ -555,7 +555,7 @@ void AudioTimingControllerDialogue::DoCommit(bool user_triggered) } else { - AssDialogue *amend = modified_lines.size() == 1 ? (*modified_lines.begin())->GetLine() : 0; + AssDialogue *amend = modified_lines.size() == 1 ? (*modified_lines.begin())->GetLine() : nullptr; commit_id = context->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME, commit_id, amend); } @@ -857,7 +857,7 @@ int AudioTimingControllerDialogue::SnapPosition(int position, int snap_range, st return position; TimeRange snap_time_range(position - snap_range, position + snap_range); - const AudioMarker *snap_marker = 0; + const AudioMarker *snap_marker = nullptr; AudioMarkerVector potential_snaps; GetMarkers(snap_time_range, potential_snaps); for (auto marker : potential_snaps) diff --git a/aegisub/src/audio_timing_karaoke.cpp b/aegisub/src/audio_timing_karaoke.cpp index 8df22b3fb..77b0334b9 100644 --- a/aegisub/src/audio_timing_karaoke.cpp +++ b/aegisub/src/audio_timing_karaoke.cpp @@ -49,10 +49,10 @@ class KaraokeMarker : public AudioMarker { FeetStyle style; public: - int GetPosition() const { return position; } - wxPen GetStyle() const { return *pen; } - FeetStyle GetFeet() const { return style; } - bool CanSnap() const { return false; } + int GetPosition() const override { return position; } + wxPen GetStyle() const override { return *pen; } + FeetStyle GetFeet() const override { return style; } + bool CanSnap() const override { return false; } void Move(int new_pos) { position = new_pos; } @@ -65,7 +65,7 @@ public: KaraokeMarker(int position) : position(position) - , pen(0) + , pen(nullptr) , style(Feet_None) { } @@ -127,25 +127,25 @@ class AudioTimingControllerKaraoke : public AudioTimingController { public: // AudioTimingController implementation - void GetMarkers(const TimeRange &range, AudioMarkerVector &out_markers) const; - wxString GetWarningMessage() const { return ""; } - TimeRange GetIdealVisibleTimeRange() const; - void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const; - TimeRange GetPrimaryPlaybackRange() const; - TimeRange GetActiveLineRange() const; - void GetLabels(const TimeRange &range, std::vector &out_labels) const; - void Next(NextMode mode); - void Prev(); - void Commit(); - void Revert(); - void AddLeadIn(); - void AddLeadOut(); - void ModifyLength(int delta, bool shift_following); - void ModifyStart(int delta); - bool IsNearbyMarker(int ms, int sensitivity) const; - std::vector OnLeftClick(int ms, bool, int sensitivity, int); - std::vector OnRightClick(int ms, bool, int, int); - void OnMarkerDrag(std::vector const& marker, int new_position, int); + void GetMarkers(const TimeRange &range, AudioMarkerVector &out_markers) const override; + wxString GetWarningMessage() const override { return ""; } + TimeRange GetIdealVisibleTimeRange() const override; + void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const override; + TimeRange GetPrimaryPlaybackRange() const override; + TimeRange GetActiveLineRange() const override; + void GetLabels(const TimeRange &range, std::vector &out_labels) const override; + void Next(NextMode mode) override; + void Prev() override; + void Commit() override; + void Revert() override; + void AddLeadIn() override; + void AddLeadOut() override; + void ModifyLength(int delta, bool shift_following) override; + void ModifyStart(int delta) override; + bool IsNearbyMarker(int ms, int sensitivity) const override; + std::vector OnLeftClick(int ms, bool, int sensitivity, int) override; + std::vector OnRightClick(int ms, bool, int, int) override; + void OnMarkerDrag(std::vector const& marker, int new_position, int) override; AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed); }; diff --git a/aegisub/src/auto4_base.cpp b/aegisub/src/auto4_base.cpp index 6422b86e0..b8f9f2b5b 100644 --- a/aegisub/src/auto4_base.cpp +++ b/aegisub/src/auto4_base.cpp @@ -197,7 +197,7 @@ namespace Automation4 { return config_dialog->CreateWindow(parent); } - return 0; + return nullptr; } void ExportFilter::LoadSettings(bool is_default, agi::Context *c) { @@ -222,7 +222,7 @@ namespace Automation4 { wxDialog w; // container dialog box w.SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); w.Create(bsr->GetParentWindow(), -1, to_wx(bsr->GetTitle())); - wxBoxSizer *s = new wxBoxSizer(wxHORIZONTAL); // sizer for putting contents in + auto s = new wxBoxSizer(wxHORIZONTAL); // sizer for putting contents in wxWindow *ww = config_dialog->CreateWindow(&w); // generate actual dialog contents s->Add(ww, 0, wxALL, 5); // add contents to dialog w.SetSizerAndFit(s); @@ -331,8 +331,8 @@ namespace Automation4 { } // AutoloadScriptManager - AutoloadScriptManager::AutoloadScriptManager(std::string const& path) - : path(path) + AutoloadScriptManager::AutoloadScriptManager(std::string path) + : path(std::move(path)) { Reload(); } @@ -454,16 +454,16 @@ namespace Automation4 { } // ScriptFactory - ScriptFactory::ScriptFactory(std::string const& engine_name, std::string const& filename_pattern) - : engine_name(engine_name) - , filename_pattern(filename_pattern) + ScriptFactory::ScriptFactory(std::string engine_name, std::string filename_pattern) + : engine_name(std::move(engine_name)) + , filename_pattern(std::move(filename_pattern)) { } void ScriptFactory::Register(std::unique_ptr factory) { if (find(Factories().begin(), Factories().end(), factory) != Factories().end()) - throw agi::InternalError("Automation 4: Attempt to register the same script factory multiple times. This should never happen.", 0); + throw agi::InternalError("Automation 4: Attempt to register the same script factory multiple times. This should never happen.", nullptr); Factories().emplace_back(std::move(factory)); } diff --git a/aegisub/src/auto4_base.h b/aegisub/src/auto4_base.h index 731c6a701..7493f7086 100644 --- a/aegisub/src/auto4_base.h +++ b/aegisub/src/auto4_base.h @@ -81,8 +81,8 @@ namespace Automation4 { public: ExportFilter(std::string const& name, std::string const& description, int priority); - wxWindow* GetConfigDialogWindow(wxWindow *parent, agi::Context *c); - void LoadSettings(bool is_default, agi::Context *c); + wxWindow* GetConfigDialogWindow(wxWindow *parent, agi::Context *c) override; + void LoadSettings(bool is_default, agi::Context *c) override; // Subclasses must implement ProcessSubs from AssExportFilter }; @@ -128,12 +128,12 @@ namespace Automation4 { BackgroundScriptRunner *bsr; int trace_level; public: - void SetIndeterminate() { impl->SetIndeterminate(); } - void SetTitle(std::string const& title) { impl->SetTitle(title); } - void SetMessage(std::string const& msg) { impl->SetMessage(msg); } - void SetProgress(int64_t cur, int64_t max) { impl->SetProgress(cur, max); } - void Log(std::string const& str) { impl->Log(str); } - bool IsCancelled() { return impl->IsCancelled(); } + void SetIndeterminate() override { impl->SetIndeterminate(); } + void SetTitle(std::string const& title) override { impl->SetTitle(title); } + void SetMessage(std::string const& msg) override { impl->SetMessage(msg); } + void SetProgress(int64_t cur, int64_t max) override { impl->SetProgress(cur, max); } + void Log(std::string const& str) override { impl->Log(str); } + bool IsCancelled() override { return impl->IsCancelled(); } /// Show the passed dialog on the GUI thread, blocking the calling /// thread until it closes @@ -225,15 +225,15 @@ namespace Automation4 { void OnSubtitlesSave(); public: LocalScriptManager(agi::Context *context); - void Reload(); + void Reload() override; }; /// Manager for scripts in the autoload directory class AutoloadScriptManager : public ScriptManager { std::string path; public: - AutoloadScriptManager(std::string const& path); - void Reload(); + AutoloadScriptManager(std::string path); + void Reload() override; }; /// Both a base class for script factories and a manager of registered @@ -254,7 +254,7 @@ namespace Automation4 { static std::vector>& Factories(); protected: - ScriptFactory(std::string const& engine_name, std::string const& filename_pattern); + ScriptFactory(std::string engine_name, std::string filename_pattern); public: virtual ~ScriptFactory() { } @@ -285,16 +285,16 @@ namespace Automation4 { public: UnknownScript(agi::fs::path const& filename) : Script(filename) { } - void Reload() { } + void Reload() override { } - std::string GetName() const { return GetFilename().stem().string(); } - std::string GetDescription() const { return from_wx(_("File was not recognized as a script")); } - std::string GetAuthor() const { return ""; } - std::string GetVersion() const { return ""; } - bool GetLoadedState() const { return false; } + std::string GetName() const override { return GetFilename().stem().string(); } + std::string GetDescription() const override { return from_wx(_("File was not recognized as a script")); } + std::string GetAuthor() const override { return ""; } + std::string GetVersion() const override { return ""; } + bool GetLoadedState() const override { return false; } - std::vector GetMacros() const { return std::vector(); } - std::vector GetFilters() const { return std::vector(); } - std::vector GetFormats() const { return std::vector(); } + std::vector GetMacros() const override { return std::vector(); } + std::vector GetFilters() const override { return std::vector(); } + std::vector GetFormats() const override { return std::vector(); } }; } diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index 8452d71c6..49f621bf9 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -88,7 +88,7 @@ namespace { lua_getfield(L, LUA_REGISTRYINDEX, "project_context"); if (!lua_islightuserdata(L, -1)) { lua_pop(L, 1); - return 0; + return nullptr; } const agi::Context * c = static_cast(lua_touserdata(L, -1)); lua_pop(L, 1); @@ -328,17 +328,17 @@ namespace Automation4 { static LuaScript* GetScriptObject(lua_State *L); // Script implementation - void Reload() { Create(); } + void Reload() override { Create(); } - std::string GetName() const { return name; } - std::string GetDescription() const { return description; } - std::string GetAuthor() const { return author; } - std::string GetVersion() const { return version; } - bool GetLoadedState() const { return L != 0; } + std::string GetName() const override { return name; } + std::string GetDescription() const override { return description; } + std::string GetAuthor() const override { return author; } + std::string GetVersion() const override { return version; } + bool GetLoadedState() const override { return L != nullptr; } - std::vector GetMacros() const { return macros; } - std::vector GetFilters() const; - std::vector GetFormats() const { return std::vector(); } + std::vector GetMacros() const override { return macros; } + std::vector GetFilters() const override; + std::vector GetFormats() const override { return std::vector(); } }; LuaScript::LuaScript(agi::fs::path const& filename) @@ -512,7 +512,7 @@ namespace Automation4 { if (macro->name() == command->name()) { luaL_error(L, "A macro named '%s' is already defined in script '%s'", - command->StrDisplay(0).utf8_str().data(), name.c_str()); + command->StrDisplay(nullptr).utf8_str().data(), name.c_str()); } } macros.push_back(command); @@ -858,7 +858,7 @@ namespace Automation4 { set_context(L, c); GetFeatureFunction("validate"); - LuaAssFile *subsobj = new LuaAssFile(L, c->ass); + auto subsobj = new LuaAssFile(L, c->ass); push_value(L, transform_selection(L, c)); int err = lua_pcall(L, 3, 2, 0); @@ -891,7 +891,7 @@ namespace Automation4 { stackcheck.check_stack(0); GetFeatureFunction("run"); - LuaAssFile *subsobj = new LuaAssFile(L, c->ass, true, true); + auto subsobj = new LuaAssFile(L, c->ass, true, true); push_value(L, transform_selection(L, c)); try { @@ -968,7 +968,7 @@ namespace Automation4 { stackcheck.check_stack(0); GetFeatureFunction("isactive"); - LuaAssFile *subsobj = new LuaAssFile(L, c->ass); + auto subsobj = new LuaAssFile(L, c->ass); push_value(L, transform_selection(L, c)); int err = lua_pcall(L, 3, 1, 0); @@ -1035,7 +1035,7 @@ namespace Automation4 { // The entire point of an export filter is to modify the file, but // setting undo points makes no sense - LuaAssFile *subsobj = new LuaAssFile(L, subs, true); + auto subsobj = new LuaAssFile(L, subs, true); assert(lua_isuserdata(L, -1)); stackcheck.check_stack(2); @@ -1066,14 +1066,14 @@ namespace Automation4 { ScriptDialog* LuaExportFilter::GenerateConfigDialog(wxWindow *parent, agi::Context *c) { if (!has_config) - return 0; + return nullptr; set_context(L, c); GetFeatureFunction("config"); // prepare function call - LuaAssFile *subsobj = new LuaAssFile(L, c->ass); + auto subsobj = new LuaAssFile(L, c->ass); // stored options lua_newtable(L); // TODO, nothing for now diff --git a/aegisub/src/auto4_lua.h b/aegisub/src/auto4_lua.h index 0102bc0f6..73dffc9ce 100644 --- a/aegisub/src/auto4_lua.h +++ b/aegisub/src/auto4_lua.h @@ -206,9 +206,9 @@ namespace Automation4 { int LuaReadBack(lua_State *L); // ScriptDialog implementation - wxWindow* CreateWindow(wxWindow *parent); - std::string Serialise(); - void Unserialise(const std::string &serialised); + wxWindow* CreateWindow(wxWindow *parent) override; + std::string Serialise() override; + void Unserialise(const std::string &serialised) override; }; class LuaFeature { @@ -244,16 +244,16 @@ namespace Automation4 { LuaCommand(lua_State *L); ~LuaCommand(); - const char* name() const { return cmd_name.c_str(); } - wxString StrMenu(const agi::Context *) const { return display; } - wxString StrDisplay(const agi::Context *) const { return display; } - wxString StrHelp() const { return help; } + const char* name() const override { return cmd_name.c_str(); } + wxString StrMenu(const agi::Context *) const override { return display; } + wxString StrDisplay(const agi::Context *) const override { return display; } + wxString StrHelp() const override { return help; } - int Type() const { return cmd_type; } + int Type() const override { return cmd_type; } - void operator()(agi::Context *c); - bool Validate(const agi::Context *c); - virtual bool IsActive(const agi::Context *c); + void operator()(agi::Context *c) override; + bool Validate(const agi::Context *c) override; + virtual bool IsActive(const agi::Context *c) override; static int LuaRegister(lua_State *L); }; @@ -263,12 +263,12 @@ namespace Automation4 { LuaDialog *config_dialog; protected: - ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c); + ScriptDialog* GenerateConfigDialog(wxWindow *parent, agi::Context *c) override; public: LuaExportFilter(lua_State *L); static int LuaRegister(lua_State *L); - void ProcessSubs(AssFile *subs, wxWindow *export_dialog); + void ProcessSubs(AssFile *subs, wxWindow *export_dialog) override; }; } diff --git a/aegisub/src/auto4_lua_assfile.cpp b/aegisub/src/auto4_lua_assfile.cpp index baaeb3d9e..f9f2570f2 100644 --- a/aegisub/src/auto4_lua_assfile.cpp +++ b/aegisub/src/auto4_lua_assfile.cpp @@ -244,7 +244,7 @@ namespace Automation4 { if (lclass == "info") result = agi::util::make_unique(get_string_field(L, "key", "info"), get_string_field(L, "value", "info")); else if (lclass == "style") { - AssStyle *sty = new AssStyle; + auto sty = new AssStyle; result.reset(sty); sty->name = get_string_field(L, "name", "style"); sty->font = get_string_field(L, "fontname", "style"); @@ -272,7 +272,7 @@ namespace Automation4 { sty->UpdateData(); } else if (lclass == "dialogue") { - AssDialogue *dia = new AssDialogue; + auto dia = new AssDialogue; result.reset(dia); dia->Comment = get_bool_field(L, "comment", "dialogue"); @@ -289,7 +289,7 @@ namespace Automation4 { } else { luaL_error(L, "Found line with unknown class: %s", lclass.c_str()); - return 0; + return nullptr; } return result; diff --git a/aegisub/src/auto4_lua_dialog.cpp b/aegisub/src/auto4_lua_dialog.cpp index a791cdb8e..eac84ca80 100644 --- a/aegisub/src/auto4_lua_dialog.cpp +++ b/aegisub/src/auto4_lua_dialog.cpp @@ -146,13 +146,13 @@ namespace Automation4 { public: Label(lua_State *L) : LuaDialogControl(L), label(get_field(L, "label")) { } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { return new wxStaticText(parent, -1, to_wx(label)); } - int GetSizerFlags() const { return wxALIGN_CENTRE_VERTICAL | wxALIGN_LEFT; } + int GetSizerFlags() const override { return wxALIGN_CENTRE_VERTICAL | wxALIGN_LEFT; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { // Label doesn't produce output, so let it be nil lua_pushnil(L); } @@ -168,7 +168,7 @@ namespace Automation4 { Edit(lua_State *L) : LuaDialogControl(L) , text(get_field(L, "value")) - , cw(0) + , cw(nullptr) { // Undocumented behaviour, 'value' is also accepted as key for text, // mostly so a text control can stand in for other things. @@ -176,18 +176,18 @@ namespace Automation4 { text = get_field(L, "text", text); } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return inline_string_encode(text); } - void UnserialiseValue(const std::string &serialised) { text = inline_string_decode(serialised); } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return inline_string_encode(text); } + void UnserialiseValue(const std::string &serialised) override { text = inline_string_decode(serialised); } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { cw = new wxTextCtrl(parent, -1, to_wx(text)); cw->SetValidator(StringBinder(&text)); cw->SetToolTip(to_wx(hint)); return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushstring(L, text.c_str()); } }; @@ -205,17 +205,17 @@ namespace Automation4 { { } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return inline_string_encode(color.GetHexFormatted()); } - void UnserialiseValue(const std::string &serialised) { color = inline_string_decode(serialised); } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return inline_string_encode(color.GetHexFormatted()); } + void UnserialiseValue(const std::string &serialised) override { color = inline_string_decode(serialised); } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { wxControl *cw = new ColourButton(parent, wxSize(50*width,10*height), alpha, color, ColorValidator(&color)); cw->SetToolTip(to_wx(hint)); return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushstring(L, color.GetHexFormatted().c_str()); } }; @@ -226,7 +226,7 @@ namespace Automation4 { Textbox(lua_State *L) : Edit(L) { } // Same serialisation interface as single-line edit - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { cw = new wxTextCtrl(parent, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, StringBinder(&text)); cw->SetMinSize(wxSize(0, 30)); cw->SetToolTip(to_wx(hint)); @@ -244,7 +244,7 @@ namespace Automation4 { public: IntEdit(lua_State *L) : Edit(L) - , cw(0) + , cw(nullptr) , value(get_field(L, "value", 0)) , min(get_field(L, "min", INT_MIN)) , max(get_field(L, "max", INT_MAX)) @@ -255,18 +255,18 @@ namespace Automation4 { } } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return std::to_string(value); } - void UnserialiseValue(const std::string &serialised) { value = atoi(serialised.c_str()); } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return std::to_string(value); } + void UnserialiseValue(const std::string &serialised) override { value = atoi(serialised.c_str()); } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { cw = new wxSpinCtrl(parent, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value); cw->SetValidator(wxGenericValidator(&value)); cw->SetToolTip(to_wx(hint)); return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushinteger(L, value); } }; @@ -282,15 +282,15 @@ namespace Automation4 { struct DoubleValidator : public wxValidator { double *value; DoubleValidator(double *value) : value(value) { } - wxValidator *Clone() const { return new DoubleValidator(value); } - bool Validate(wxWindow*) { return true; } + wxValidator *Clone() const override { return new DoubleValidator(value); } + bool Validate(wxWindow*) override { return true; } - bool TransferToWindow() { + bool TransferToWindow() override { static_cast(GetWindow())->SetValue(*value); return true; } - bool TransferFromWindow() { + bool TransferFromWindow() override { auto ctrl = static_cast(GetWindow()); #ifndef wxHAS_NATIVE_SPINCTRLDOUBLE wxFocusEvent evt; @@ -308,7 +308,7 @@ namespace Automation4 { , min(get_field(L, "min", -DBL_MAX)) , max(get_field(L, "max", DBL_MAX)) , step(get_field(L, "step", 0.0)) - , scd(0) + , scd(nullptr) { if (min >= max) { max = DBL_MAX; @@ -316,11 +316,11 @@ namespace Automation4 { } } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return std::to_string(value); } - void UnserialiseValue(const std::string &serialised) { value = atof(serialised.c_str()); } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return std::to_string(value); } + void UnserialiseValue(const std::string &serialised) override { value = atof(serialised.c_str()); } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { if (step > 0) { scd = new wxSpinCtrlDouble(parent, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value, step); scd->SetValidator(DoubleValidator(&value)); @@ -335,7 +335,7 @@ namespace Automation4 { return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushnumber(L, value); } }; @@ -350,23 +350,23 @@ namespace Automation4 { Dropdown(lua_State *L) : LuaDialogControl(L) , value(get_field(L, "value")) - , cw(0) + , cw(nullptr) { lua_getfield(L, -1, "items"); read_string_array(L, items); } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return inline_string_encode(value); } - void UnserialiseValue(const std::string &serialised) { value = inline_string_decode(serialised); } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return inline_string_encode(value); } + void UnserialiseValue(const std::string &serialised) override { value = inline_string_decode(serialised); } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { cw = new wxComboBox(parent, -1, to_wx(value), wxDefaultPosition, wxDefaultSize, to_wx(items), wxCB_READONLY, StringBinder(&value)); cw->SetToolTip(to_wx(hint)); return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushstring(L, value.c_str()); } }; @@ -381,15 +381,15 @@ namespace Automation4 { : LuaDialogControl(L) , label(get_field(L, "label")) , value(get_field(L, "value", false)) - , cw(0) + , cw(nullptr) { } - bool CanSerialiseValue() const { return true; } - std::string SerialiseValue() const { return value ? "1" : "0"; } - void UnserialiseValue(const std::string &serialised) { value = serialised != "0"; } + bool CanSerialiseValue() const override { return true; } + std::string SerialiseValue() const override { return value ? "1" : "0"; } + void UnserialiseValue(const std::string &serialised) override { value = serialised != "0"; } - wxControl *Create(wxWindow *parent) { + wxControl *Create(wxWindow *parent) override { cw = new wxCheckBox(parent, -1, to_wx(label)); cw->SetValidator(wxGenericValidator(&value)); cw->SetToolTip(to_wx(hint)); @@ -397,7 +397,7 @@ namespace Automation4 { return cw; } - void LuaReadBack(lua_State *L) { + void LuaReadBack(lua_State *L) override { lua_pushboolean(L, value); } }; @@ -407,7 +407,7 @@ namespace Automation4 { LuaDialog::LuaDialog(lua_State *L, bool include_buttons) : use_buttons(include_buttons) , button_pushed(-1) - , window(0) + , window(nullptr) { LOG_D("automation/lua/dialog") << "creating LuaDialoug, addr: " << this; diff --git a/aegisub/src/auto4_lua_progresssink.cpp b/aegisub/src/auto4_lua_progresssink.cpp index 0e7370b4a..907d0aa1b 100644 --- a/aegisub/src/auto4_lua_progresssink.cpp +++ b/aegisub/src/auto4_lua_progresssink.cpp @@ -203,7 +203,7 @@ namespace Automation4 { if (must_exist) flags |= wxFD_FILE_MUST_EXIST; - wxFileDialog diag(0, message, dir, file, wildcard, flags); + wxFileDialog diag(nullptr, message, dir, file, wildcard, flags); if (ps->ShowDialog(&diag) == wxID_CANCEL) { lua_pushnil(L); return 1; diff --git a/aegisub/src/base_grid.cpp b/aegisub/src/base_grid.cpp index 7fd3514ca..dd3f2201e 100644 --- a/aegisub/src/base_grid.cpp +++ b/aegisub/src/base_grid.cpp @@ -114,7 +114,7 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, { scrollBar->SetScrollbar(0,10,100,10); - wxBoxSizer *scrollbarpositioner = new wxBoxSizer(wxHORIZONTAL); + auto scrollbarpositioner = new wxBoxSizer(wxHORIZONTAL); scrollbarpositioner->AddStretchSpacer(); scrollbarpositioner->Add(scrollBar, 0, wxEXPAND, 0); @@ -920,7 +920,7 @@ void BaseGrid::SetColumnWidths() { } AssDialogue *BaseGrid::GetDialogue(int n) const { - if (static_cast(n) >= index_line_map.size()) return 0; + if (static_cast(n) >= index_line_map.size()) return nullptr; return index_line_map[n]; } @@ -1043,7 +1043,7 @@ void BaseGrid::SetSelectedSet(const Selection &new_selection) { void BaseGrid::SetActiveLine(AssDialogue *new_line) { if (new_line != active_line) { - assert(new_line == 0 || line_index_map.count(new_line)); + assert(new_line == nullptr || line_index_map.count(new_line)); active_line = new_line; AnnounceActiveLineChanged(active_line); MakeRowVisible(GetDialogueIndex(active_line)); diff --git a/aegisub/src/base_grid.h b/aegisub/src/base_grid.h index 72ec95d4d..7894d8393 100644 --- a/aegisub/src/base_grid.h +++ b/aegisub/src/base_grid.h @@ -128,14 +128,14 @@ protected: public: // SelectionController implementation - void SetActiveLine(AssDialogue *new_line); - AssDialogue * GetActiveLine() const { return active_line; } - void SetSelectedSet(const Selection &new_selection); - void GetSelectedSet(Selection &res) const { res = selection; } - Selection const& GetSelectedSet() const { return selection; } - void SetSelectionAndActive(Selection const& new_selection, AssDialogue *new_line);; - void NextLine(); - void PrevLine(); + void SetActiveLine(AssDialogue *new_line) override; + AssDialogue * GetActiveLine() const override { return active_line; } + void SetSelectedSet(const Selection &new_selection) override; + void GetSelectedSet(Selection &res) const override { res = selection; } + Selection const& GetSelectedSet() const override { return selection; } + void SetSelectionAndActive(Selection const& new_selection, AssDialogue *new_line) override;; + void NextLine() override; + void PrevLine() override; void BeginBatch(); void EndBatch(); diff --git a/aegisub/src/block_cache.h b/aegisub/src/block_cache.h index db7b83edc..92e35fb2e 100644 --- a/aegisub/src/block_cache.h +++ b/aegisub/src/block_cache.h @@ -161,7 +161,7 @@ public: /// /// The factory object passed must respond well to copying. DataBlockCache(size_t block_count, BlockFactoryT factory = BlockFactoryT()) - : factory(factory) + : factory(std::move(factory)) { SetBlockCount(block_count); } @@ -250,7 +250,7 @@ public: { mb.blocks[block_index] = factory.ProduceBlock(i); b = mb.blocks[block_index].get(); - assert(b != 0); + assert(b != nullptr); if (created) *created = true; } diff --git a/aegisub/src/colour_button.cpp b/aegisub/src/colour_button.cpp index 60925454b..98d966c14 100644 --- a/aegisub/src/colour_button.cpp +++ b/aegisub/src/colour_button.cpp @@ -28,7 +28,7 @@ wxDEFINE_EVENT(EVT_COLOR, wxThreadEvent); ColourButton::ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi::Color col, wxValidator const& validator) : wxButton(parent, -1, "", wxDefaultPosition, wxSize(size.GetWidth() + 6, size.GetHeight() + 6), 0, validator) , bmp(size) -, colour(col) +, colour(std::move(col)) { UpdateBitmap(); Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent&) { diff --git a/aegisub/src/colour_button.h b/aegisub/src/colour_button.h index a35a9821a..ea8ce5c45 100644 --- a/aegisub/src/colour_button.h +++ b/aegisub/src/colour_button.h @@ -46,11 +46,11 @@ public: struct ColorValidator : public wxValidator { agi::Color *color; ColorValidator(agi::Color *color) : color(color) { } - wxValidator *Clone() const { return new ColorValidator(color); } - bool Validate(wxWindow*) { return true; } - bool TransferToWindow() { return true; } + wxValidator *Clone() const override { return new ColorValidator(color); } + bool Validate(wxWindow*) override { return true; } + bool TransferToWindow() override { return true; } - bool TransferFromWindow() { + bool TransferFromWindow() override { *color = static_cast(GetWindow())->GetColor(); return true; } diff --git a/aegisub/src/command/app.cpp b/aegisub/src/command/app.cpp index 92edc6ff1..78a931821 100644 --- a/aegisub/src/command/app.cpp +++ b/aegisub/src/command/app.cpp @@ -62,7 +62,7 @@ struct app_about : public Command { STR_DISP("About") STR_HELP("About Aegisub") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AboutScreen(c->parent).ShowModal(); } }; @@ -74,15 +74,15 @@ struct app_display_audio_subs : public Command { STR_HELP("Display audio and the subtitles grid only") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - void operator()(agi::Context *) { + void operator()(agi::Context *) override { wxGetApp().frame->SetDisplayMode(0,1); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->audioController->IsAudioOpen(); } - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return wxGetApp().frame->IsAudioShown() && !wxGetApp().frame->IsVideoShown(); } }; @@ -94,15 +94,15 @@ struct app_display_full : public Command { STR_HELP("Display audio, video and then subtitles grid") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().frame->SetDisplayMode(1,1); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->audioController->IsAudioOpen() && c->videoController->IsLoaded() && !c->dialog->Get(); } - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return wxGetApp().frame->IsAudioShown() && wxGetApp().frame->IsVideoShown(); } }; @@ -114,11 +114,11 @@ struct app_display_subs : public Command { STR_HELP("Display the subtitles grid only") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().frame->SetDisplayMode(0,0); } - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return !wxGetApp().frame->IsAudioShown() && !wxGetApp().frame->IsVideoShown(); } }; @@ -130,15 +130,15 @@ struct app_display_video_subs : public Command { STR_HELP("Display video and the subtitles grid only") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().frame->SetDisplayMode(1,0); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded() && !c->dialog->Get(); } - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return !wxGetApp().frame->IsAudioShown() && wxGetApp().frame->IsVideoShown(); } }; @@ -149,7 +149,7 @@ struct app_exit : public Command { STR_DISP("Exit") STR_HELP("Exit the application") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().frame->Close(); } }; @@ -160,7 +160,7 @@ struct app_language : public Command { STR_DISP("Language") STR_HELP("Select Aegisub interface language") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { // Get language wxString new_language = wxGetApp().locale.PickLanguage(); if (!new_language) return; @@ -184,7 +184,7 @@ struct app_log : public Command { STR_DISP("Log window") STR_HELP("View the event log") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -195,7 +195,7 @@ struct app_new_window : public Command { STR_DISP("New Window") STR_HELP("Open a new application window") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { RestartAegisub(); } }; @@ -206,7 +206,7 @@ struct app_options : public Command { STR_DISP("Options") STR_HELP("Configure Aegisub") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { try { while (Preferences(c->parent).ShowModal() < 0); } catch (agi::Exception& e) { @@ -222,11 +222,11 @@ struct app_toggle_global_hotkeys : public Command { STR_HELP("Toggle global hotkey overrides (Medusa Mode)") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Medusa Timing Hotkeys")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { agi::OptionValue *opt = OPT_SET("Audio/Medusa Timing Hotkeys"); opt->SetBool(!opt->GetBool()); } @@ -237,17 +237,17 @@ struct app_toggle_toolbar : public Command { STR_HELP("Toggle the main toolbar") CMD_TYPE(COMMAND_DYNAMIC_NAME) - wxString StrMenu(const agi::Context *) const { + wxString StrMenu(const agi::Context *) const override { return OPT_GET("App/Show Toolbar")->GetBool() ? _("Hide Toolbar") : _("Show Toolbar"); } - wxString StrDisplay(const agi::Context *) const { - return StrMenu(0); + wxString StrDisplay(const agi::Context *) const override { + return StrMenu(nullptr); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { agi::OptionValue *opt = OPT_SET("App/Show Toolbar"); opt->SetBool(!opt->GetBool()); } @@ -259,7 +259,7 @@ struct app_updates : public Command { STR_DISP("Check for Updates") STR_HELP("Check to see if there is a new version of Aegisub available") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { PerformVersionCheck(true); } }; diff --git a/aegisub/src/command/audio.cpp b/aegisub/src/command/audio.cpp index 3b6920e08..827b70cc2 100644 --- a/aegisub/src/command/audio.cpp +++ b/aegisub/src/command/audio.cpp @@ -54,7 +54,7 @@ namespace { struct validate_audio_open : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->audioController->IsAudioOpen(); } }; @@ -65,7 +65,7 @@ struct audio_close : public validate_audio_open { STR_DISP("Close Audio") STR_HELP("Close the currently open audio file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->audioController->CloseAudio(); } }; @@ -76,7 +76,7 @@ struct audio_open : public Command { STR_DISP("Open Audio File") STR_HELP("Open an audio file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxString str = _("Audio Formats") + " (*.aac,*.ac3,*.ape,*.dts,*.flac,*.m4a,*.mka,*.mp3,*.mp4,*.ogg,*.w64,*.wav,*.wma)|*.aac;*.ac3;*.ape;*.dts;*.flac;*.m4a;*.mka;*.mp3;*.mp4;*.ogg;*.w64;*.wav;*.wma|" + _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts|" + _("All Files") + " (*.*)|*.*"; @@ -99,7 +99,7 @@ struct audio_open_blank : public Command { STR_DISP("Open 2h30 Blank Audio") STR_HELP("Open a 150 minutes blank audio clip, for debugging") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { try { c->audioController->OpenAudio("dummy-audio:silence?sr=44100&bd=16&ch=1&ln=396900000"); } @@ -115,7 +115,7 @@ struct audio_open_noise : public Command { STR_DISP("Open 2h30 Noise Audio") STR_HELP("Open a 150 minutes noise-filled audio clip, for debugging") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { try { c->audioController->OpenAudio("dummy-audio:noise?sr=44100&bd=16&ch=1&ln=396900000"); } @@ -132,11 +132,11 @@ struct audio_open_video : public Command { STR_HELP("Open the audio from the current video file") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { try { c->audioController->OpenAudio(c->videoController->GetVideoName()); } @@ -154,11 +154,11 @@ struct audio_view_spectrum : public Command { STR_HELP("Display audio as a frequency-power spectrograph") CMD_TYPE(COMMAND_RADIO) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Spectrum")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Audio/Spectrum")->SetBool(true); } }; @@ -170,11 +170,11 @@ struct audio_view_waveform : public Command { STR_HELP("Display audio as a linear amplitude graph") CMD_TYPE(COMMAND_RADIO) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return !OPT_GET("Audio/Spectrum")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Audio/Spectrum")->SetBool(false); } }; @@ -186,11 +186,11 @@ struct audio_save_clip : public Command { STR_HELP("Save an audio clip of the selected line") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->audioController->IsAudioOpen() && !c->selectionController->GetSelectedSet().empty(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SubtitleSelection sel = c->selectionController->GetSelectedSet(); if (sel.empty()) return; @@ -212,7 +212,7 @@ struct audio_play_current_selection : public validate_audio_open { STR_DISP("Play current audio selection") STR_HELP("Play the current audio selection, ignoring changes made while playing") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->audioController->PlayRange(c->audioController->GetPrimaryPlaybackRange()); } @@ -224,7 +224,7 @@ struct audio_play_current_line : public validate_audio_open { STR_DISP("Play current line") STR_HELP("Play the audio for the current line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) @@ -238,7 +238,7 @@ struct audio_play_selection : public validate_audio_open { STR_DISP("Play audio selection") STR_HELP("Play audio until the end of the selection is reached") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->audioController->PlayPrimaryRange(); } @@ -250,7 +250,7 @@ struct audio_play_toggle : public validate_audio_open { STR_DISP("Play audio selection or stop") STR_HELP("Play selection, or stop playback if it's already playing") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->IsPlaying()) c->audioController->Stop(); else { @@ -267,11 +267,11 @@ struct audio_stop : public Command { STR_HELP("Stop audio and video playback") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->audioController->IsPlaying(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->audioController->Stop(); c->videoController->Stop(); } @@ -283,7 +283,7 @@ struct audio_play_before : public validate_audio_open { STR_DISP("Play 500 ms before selection") STR_HELP("Play 500 ms before selection") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); int begin = c->audioController->GetPrimaryPlaybackRange().begin(); c->audioController->PlayRange(TimeRange(begin - 500, begin)); @@ -296,7 +296,7 @@ struct audio_play_after : public validate_audio_open { STR_DISP("Play 500 ms after selection") STR_HELP("Play 500 ms after selection") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); int end = c->audioController->GetPrimaryPlaybackRange().end(); c->audioController->PlayRange(TimeRange(end, end + 500)); @@ -309,7 +309,7 @@ struct audio_play_end : public validate_audio_open { STR_DISP("Play last 500 ms of selection") STR_HELP("Play last 500 ms of selection") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); TimeRange times(c->audioController->GetPrimaryPlaybackRange()); c->audioController->PlayToEndOfPrimary(times.end() - std::min(500, times.length())); @@ -322,7 +322,7 @@ struct audio_play_begin : public validate_audio_open { STR_DISP("Play first 500 ms of selection") STR_HELP("Play first 500 ms of selection") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); TimeRange times(c->audioController->GetPrimaryPlaybackRange()); c->audioController->PlayRange(TimeRange( @@ -337,7 +337,7 @@ struct audio_play_to_end : public validate_audio_open { STR_DISP("Play from selection start to end of file") STR_HELP("Play from selection start to end of file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->audioController->PlayToEnd(c->audioController->GetPrimaryPlaybackRange().begin()); } @@ -349,7 +349,7 @@ struct audio_commit : public validate_audio_open { STR_DISP("Commit") STR_HELP("Commit any pending audio timing changes") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) { tc->Commit(); @@ -365,7 +365,7 @@ struct audio_commit_default : public validate_audio_open { STR_DISP("Commit and use default timing for next line") STR_HELP("Commit any pending audio timing changes and reset the next line's times to the default") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) { tc->Commit(); @@ -380,7 +380,7 @@ struct audio_commit_next : public validate_audio_open { STR_DISP("Commit and move to next line") STR_HELP("Commit any pending audio timing changes and move to the next line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) { tc->Commit(); @@ -395,7 +395,7 @@ struct audio_commit_stay : public validate_audio_open { STR_DISP("Commit and stay on current line") STR_HELP("Commit any pending audio timing changes and stay on the current line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) tc->Commit(); } @@ -407,7 +407,7 @@ struct audio_go_to : public validate_audio_open { STR_DISP("Go to selection") STR_HELP("Scroll the audio display to center on the current audio selection") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->audioBox->ScrollToActiveLine(); } }; @@ -418,7 +418,7 @@ struct audio_scroll_left : public validate_audio_open { STR_DISP("Scroll left") STR_HELP("Scroll the audio display left") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->audioBox->ScrollAudioBy(-128); } }; @@ -429,7 +429,7 @@ struct audio_scroll_right : public validate_audio_open { STR_DISP("Scroll right") STR_HELP("Scroll the audio display right") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->audioBox->ScrollAudioBy(128); } }; @@ -445,11 +445,11 @@ struct audio_autoscroll : public Command { STR_HELP("Auto scroll audio display to selected line") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Auto/Scroll")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { toggle("Audio/Auto/Scroll"); } }; @@ -461,11 +461,11 @@ struct audio_autocommit : public Command { STR_HELP("Automatically commit all changes") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Auto/Commit")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { toggle("Audio/Auto/Commit"); } }; @@ -477,11 +477,11 @@ struct audio_autonext : public Command { STR_HELP("Automatically go to next line on commit") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Next Line on Commit")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { toggle("Audio/Next Line on Commit"); } }; @@ -493,11 +493,11 @@ struct audio_toggle_spectrum : public Command { STR_HELP("Spectrum analyzer mode") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Spectrum")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { toggle("Audio/Spectrum"); } }; @@ -509,11 +509,11 @@ struct audio_vertical_link : public Command { STR_HELP("Link vertical zoom and volume sliders") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Audio/Link")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { toggle("Audio/Link"); } }; @@ -525,10 +525,10 @@ struct audio_karaoke : public Command { STR_HELP("Toggle karaoke mode") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->karaoke->IsEnabled(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->karaoke->SetEnabled(!c->karaoke->IsEnabled()); } }; diff --git a/aegisub/src/command/automation.cpp b/aegisub/src/command/automation.cpp index 9d9cbf8b0..9055338d1 100644 --- a/aegisub/src/command/automation.cpp +++ b/aegisub/src/command/automation.cpp @@ -54,7 +54,7 @@ struct reload_all : public Command { STR_DISP("Reload Automation scripts") STR_HELP("Reload all Automation scripts and rescan the autoload folder") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().global_scripts->Reload(); c->local_scripts->Reload(); StatusTimeout(_("Reloaded all Automation scripts")); @@ -67,7 +67,7 @@ struct reload_autoload : public Command { STR_DISP("Reload autoload Automation scripts") STR_HELP("Rescan the Automation autoload folder") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxGetApp().global_scripts->Reload(); StatusTimeout(_("Reloaded autoload Automation scripts")); } @@ -79,7 +79,7 @@ struct open_manager : public Command { STR_DISP("Automation") STR_HELP("Open automation manager") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -90,7 +90,7 @@ struct meta : public Command { STR_DISP("Automation") STR_HELP("Open automation manager. Ctrl: Rescan autoload folder. Ctrl+Shift: Rescan autoload folder and reload all automation scripts") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (wxGetMouseState().CmdDown()) { if (wxGetMouseState().ShiftDown()) cmd::call("am/reload", c); diff --git a/aegisub/src/command/command.cpp b/aegisub/src/command/command.cpp index 71446c2d4..41f9987a6 100644 --- a/aegisub/src/command/command.cpp +++ b/aegisub/src/command/command.cpp @@ -26,7 +26,7 @@ namespace cmd { typedef std::map>::iterator iterator; static iterator find_command(std::string const& name) { - iterator it = cmd_map.find(name); + auto it = cmd_map.find(name); if (it == cmd_map.end()) throw CommandNotFound(from_wx(wxString::Format(_("'%s' is not a valid command name"), to_wx(name)))); return it; diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index 47bb3c3c6..21b84a493 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -74,21 +74,21 @@ namespace { struct validate_sel_nonempty : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() > 0; } }; struct validate_video_and_sel_nonempty : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded() && !c->selectionController->GetSelectedSet().empty(); } }; struct validate_sel_multiple : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() > 1; } }; @@ -202,8 +202,8 @@ void set_tag(AssDialogue *line, boost::ptr_vector &blocks, std int start = at_end ? sel_end : sel_start; int blockn = block_at_pos(line->Text, start); - AssDialogueBlockPlain *plain = 0; - AssDialogueBlockOverride *ovr = 0; + AssDialogueBlockPlain *plain = nullptr; + AssDialogueBlockOverride *ovr = nullptr; while (blockn >= 0) { AssDialogueBlock *block = &blocks[blockn]; if (dynamic_cast(block)) @@ -267,12 +267,12 @@ void set_tag(AssDialogue *line, boost::ptr_vector &blocks, std } } -void commit_text(agi::Context const * const c, wxString const& desc, int sel_start = -1, int sel_end = -1, int *commit_id = 0) { +void commit_text(agi::Context const * const c, wxString const& desc, int sel_start = -1, int sel_end = -1, int *commit_id = nullptr) { SubtitleSelection const& sel = c->selectionController->GetSelectedSet(); std::string text = c->selectionController->GetActiveLine()->Text; for_each(sel.begin(), sel.end(), [&](AssDialogue *d) { d->Text = text; }); - int new_commit_id = c->ass->Commit(desc, AssFile::COMMIT_DIAG_TEXT, commit_id ? *commit_id : -1, sel.size() == 1 ? *sel.begin() : 0); + int new_commit_id = c->ass->Commit(desc, AssFile::COMMIT_DIAG_TEXT, commit_id ? *commit_id : -1, sel.size() == 1 ? *sel.begin() : nullptr); if (commit_id) *commit_id = new_commit_id; if (sel_start >= 0 && sel_end >= 0) @@ -335,7 +335,7 @@ struct edit_color_primary : public Command { STR_DISP("Primary Color") STR_HELP("Set the primary fill color (\\c) at the cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { show_color_picker(c, &AssStyle::primary, "\\c", "\\1c", "\\1a"); } }; @@ -346,7 +346,7 @@ struct edit_color_secondary : public Command { STR_DISP("Secondary Color") STR_HELP("Set the secondary (karaoke) fill color (\\2c) at the cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { show_color_picker(c, &AssStyle::secondary, "\\2c", "", "\\2a"); } }; @@ -357,7 +357,7 @@ struct edit_color_outline : public Command { STR_DISP("Outline Color") STR_HELP("Set the outline color (\\3c) at the cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { show_color_picker(c, &AssStyle::outline, "\\3c", "", "\\3a"); } }; @@ -368,7 +368,7 @@ struct edit_color_shadow : public Command { STR_DISP("Shadow Color") STR_HELP("Set the shadow color (\\4c) at the cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { show_color_picker(c, &AssStyle::shadow, "\\4c", "", "\\4a"); } }; @@ -379,7 +379,7 @@ struct edit_style_bold : public Command { STR_DISP("Toggle Bold") STR_HELP("Toggle bold (\\b) for the current selection or at the current cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { toggle_override_tag(c, &AssStyle::bold, "\\b", _("toggle bold")); } }; @@ -390,7 +390,7 @@ struct edit_style_italic : public Command { STR_DISP("Toggle Italics") STR_HELP("Toggle italics (\\i) for the current selection or at the current cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { toggle_override_tag(c, &AssStyle::italic, "\\i", _("toggle italic")); } }; @@ -401,7 +401,7 @@ struct edit_style_underline : public Command { STR_DISP("Toggle Underline") STR_HELP("Toggle underline (\\u) for the current selection or at the current cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { toggle_override_tag(c, &AssStyle::underline, "\\u", _("toggle underline")); } }; @@ -412,7 +412,7 @@ struct edit_style_strikeout : public Command { STR_DISP("Toggle Strikeout") STR_HELP("Toggle strikeout (\\s) for the current selection or at the current cursor position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { toggle_override_tag(c, &AssStyle::strikeout, "\\s", _("toggle strikeout")); } }; @@ -423,7 +423,7 @@ struct edit_font : public Command { STR_DISP("Font Face") STR_HELP("Select a font face and size") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *const line = c->selectionController->GetActiveLine(); boost::ptr_vector blocks(line->ParseTags()); const int blockn = block_at_pos(line->Text, c->textSelectionController->GetInsertionPoint()); @@ -468,7 +468,7 @@ struct edit_find_replace : public Command { STR_DISP("Find and Replace") STR_HELP("Find and replace words in subtitles") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogSearchReplace::Show(c, true); } @@ -531,7 +531,7 @@ struct edit_line_copy : public validate_sel_nonempty { STR_DISP("Copy Lines") STR_HELP("Copy subtitles to the clipboard") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { // Ideally we'd let the control's keydown handler run and only deal // with the events not processed by it, but that doesn't seem to be // possible with how wx implements key event handling - the native @@ -553,7 +553,7 @@ struct edit_line_cut: public validate_sel_nonempty { STR_DISP("Cut Lines") STR_HELP("Cut subtitles") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (wxTextEntryBase *ctrl = dynamic_cast(c->parent->FindFocus())) ctrl->Cut(); else { @@ -569,7 +569,7 @@ struct edit_line_delete : public validate_sel_nonempty { STR_DISP("Delete Lines") STR_HELP("Delete currently selected lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { delete_lines(c, _("delete lines")); } }; @@ -603,7 +603,7 @@ static void duplicate_lines(agi::Context *c, int shift) { // after the selected block do { auto old_diag = static_cast(&*start); - auto new_diag = new AssDialogue(*old_diag); + auto new_diag = new AssDialogue(*old_diag); c->ass->Line.insert(insert_pos, *new_diag); new_sel.insert(new_diag); @@ -653,7 +653,7 @@ struct edit_line_duplicate : public validate_sel_nonempty { STR_DISP("Duplicate Lines") STR_HELP("Duplicate the selected lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { duplicate_lines(c, 0); } }; @@ -665,7 +665,7 @@ struct edit_line_duplicate_shift : public validate_video_and_sel_nonempty { STR_HELP("Split the current line into a line which ends on the current frame and a line which starts on the next frame") CMD_TYPE(COMMAND_VALIDATE) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { duplicate_lines(c, 1); } }; @@ -677,7 +677,7 @@ struct edit_line_duplicate_shift_back : public validate_video_and_sel_nonempty { STR_HELP("Split the current line into a line which ends on the previous frame and a line which starts on the current frame") CMD_TYPE(COMMAND_VALIDATE) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { duplicate_lines(c, -1); } }; @@ -685,7 +685,7 @@ struct edit_line_duplicate_shift_back : public validate_video_and_sel_nonempty { static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDialogue *), wxString const& message) { SubtitleSelection sel = c->selectionController->GetSelectedSet(); - AssDialogue *first = 0; + AssDialogue *first = nullptr; for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ) { AssDialogue *diag = dynamic_cast(&*it++); if (!diag || !sel.count(diag)) @@ -723,7 +723,7 @@ struct edit_line_join_as_karaoke : public validate_sel_multiple { STR_DISP("As Karaoke") STR_HELP("Join selected lines in a single one, as karaoke") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { combine_lines(c, combine_karaoke, _("join as karaoke")); } }; @@ -734,7 +734,7 @@ struct edit_line_join_concatenate : public validate_sel_multiple { STR_DISP("Concatenate") STR_HELP("Join selected lines in a single one, concatenating text together") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { combine_lines(c, combine_concat, _("join lines")); } }; @@ -745,7 +745,7 @@ struct edit_line_join_keep_first : public validate_sel_multiple { STR_DISP("Keep First") STR_HELP("Join selected lines in a single one, keeping text of first and discarding remaining") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { combine_lines(c, combine_drop, _("join lines")); } }; @@ -788,7 +788,7 @@ struct edit_line_paste : public Command { STR_HELP("Paste subtitles") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *) { + bool Validate(const agi::Context *) override { bool can_paste = false; if (wxTheClipboard->Open()) { can_paste = wxTheClipboard->IsSupported(wxDF_TEXT); @@ -797,7 +797,7 @@ struct edit_line_paste : public Command { return can_paste; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (wxTextEntryBase *ctrl = dynamic_cast(c->parent->FindFocus())) { if (!try_paste_lines(c)) ctrl->Paste(); @@ -819,7 +819,7 @@ struct edit_line_paste_over : public Command { STR_HELP("Paste subtitles over others") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { bool can_paste = !c->selectionController->GetSelectedSet().empty(); if (can_paste && wxTheClipboard->Open()) { can_paste = wxTheClipboard->IsSupported(wxDF_TEXT); @@ -828,7 +828,7 @@ struct edit_line_paste_over : public Command { return can_paste; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto const& sel = c->selectionController->GetSelectedSet(); std::vector pasteOverOptions; @@ -911,7 +911,7 @@ struct edit_line_recombine : public validate_sel_multiple { STR_DISP("Recombine Lines") STR_HELP("Recombine subtitles which have been split and merged") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto sel_set = c->selectionController->GetSelectedSet(); if (sel_set.size() < 2) return; @@ -986,7 +986,7 @@ struct edit_line_split_by_karaoke : public validate_sel_nonempty { STR_DISP("Split Lines (by karaoke)") STR_HELP("Use karaoke timing to split line into multiple smaller lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssKaraoke::SplitLines(c->selectionController->GetSelectedSet(), c); } }; @@ -996,7 +996,7 @@ void split_lines(agi::Context *c, Func&& set_time) { int pos = c->textSelectionController->GetSelectionStart(); AssDialogue *n1 = c->selectionController->GetActiveLine(); - AssDialogue *n2 = new AssDialogue(*n1); + auto n2 = new AssDialogue(*n1); c->ass->Line.insert(++c->ass->Line.iterator_to(*n1), *n2); std::string orig = n1->Text; @@ -1014,7 +1014,7 @@ struct edit_line_split_estimate : public validate_video_and_sel_nonempty { STR_DISP("Split at cursor (estimate times)") STR_HELP("Split the current line at the cursor, dividing the original line's duration between the new ones") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { split_lines(c, [](AssDialogue *n1, AssDialogue *n2) { size_t len = n1->Text.get().size() + n2->Text.get().size(); if (!len) return; @@ -1030,7 +1030,7 @@ struct edit_line_split_preserve : public validate_sel_nonempty { STR_DISP("Split at cursor (preserve times)") STR_HELP("Split the current line at the cursor, setting both lines to the original line's times") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { split_lines(c, [](AssDialogue *, AssDialogue *) { }); } }; @@ -1041,7 +1041,7 @@ struct edit_line_split_video : public validate_video_and_sel_nonempty { STR_DISP("Split at cursor (at video frame)") STR_HELP("Split the current line at the cursor, dividing the line's duration at the current video frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { split_lines(c, [&](AssDialogue *n1, AssDialogue *n2) { int cur_frame = mid( c->videoController->FrameAtTime(n1->Start, agi::vfr::START), @@ -1057,22 +1057,22 @@ struct edit_redo : public Command { STR_HELP("Redo last undone action") CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME) - wxString StrMenu(const agi::Context *c) const { + wxString StrMenu(const agi::Context *c) const override { return c->subsController->IsRedoStackEmpty() ? _("Nothing to &redo") : wxString::Format(_("&Redo %s"), c->subsController->GetRedoDescription()); } - wxString StrDisplay(const agi::Context *c) const { + wxString StrDisplay(const agi::Context *c) const override { return c->subsController->IsRedoStackEmpty() ? _("Nothing to redo") : wxString::Format(_("Redo %s"), c->subsController->GetRedoDescription()); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return !c->subsController->IsRedoStackEmpty(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->subsController->Redo(); } }; @@ -1082,22 +1082,22 @@ struct edit_undo : public Command { STR_HELP("Undo last action") CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME) - wxString StrMenu(const agi::Context *c) const { + wxString StrMenu(const agi::Context *c) const override { return c->subsController->IsUndoStackEmpty() ? _("Nothing to &undo") : wxString::Format(_("&Undo %s"), c->subsController->GetUndoDescription()); } - wxString StrDisplay(const agi::Context *c) const { + wxString StrDisplay(const agi::Context *c) const override { return c->subsController->IsUndoStackEmpty() ? _("Nothing to undo") : wxString::Format(_("Undo %s"), c->subsController->GetUndoDescription()); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return !c->subsController->IsUndoStackEmpty(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->subsController->Undo(); } }; @@ -1108,7 +1108,7 @@ struct edit_revert : public Command { STR_MENU("Revert") STR_HELP("Revert the active line to its initial state (shown in the upper editor)") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *line = c->selectionController->GetActiveLine(); line->Text = c->initialLineState->GetInitialText(); c->ass->Commit(_("revert line"), AssFile::COMMIT_DIAG_TEXT, -1, line); @@ -1121,7 +1121,7 @@ struct edit_clear : public Command { STR_MENU("Clear") STR_HELP("Clear the current line's text") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *line = c->selectionController->GetActiveLine(); line->Text = ""; c->ass->Commit(_("clear line"), AssFile::COMMIT_DIAG_TEXT, -1, line); @@ -1135,7 +1135,7 @@ struct edit_clear_text : public Command { STR_MENU("Clear Text") STR_HELP("Clear the current line's text, leaving override tags") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *line = c->selectionController->GetActiveLine(); boost::ptr_vector blocks(line->ParseTags()); line->Text = join(blocks @@ -1152,7 +1152,7 @@ struct edit_insert_original : public Command { STR_MENU("Insert Original") STR_HELP("Insert the original line text at the cursor") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *line = c->selectionController->GetActiveLine(); int sel_start = c->textSelectionController->GetSelectionStart(); int sel_end = c->textSelectionController->GetSelectionEnd(); diff --git a/aegisub/src/command/grid.cpp b/aegisub/src/command/grid.cpp index 33d435459..cd6985e06 100644 --- a/aegisub/src/command/grid.cpp +++ b/aegisub/src/command/grid.cpp @@ -53,7 +53,7 @@ struct grid_line_next : public Command { STR_DISP("Next Line") STR_HELP("Move to the next subtitle line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->selectionController->NextLine(); } }; @@ -64,7 +64,7 @@ struct grid_line_next_create : public Command { STR_DISP("Next Line") STR_HELP("Move to the next subtitle line, creating a new one if needed") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AudioTimingController *tc = c->audioController->GetTimingController(); if (tc) tc->Commit(); @@ -72,7 +72,7 @@ struct grid_line_next_create : public Command { AssDialogue *cur = c->selectionController->GetActiveLine(); c->selectionController->NextLine(); if (cur == c->selectionController->GetActiveLine()) { - AssDialogue *newline = new AssDialogue; + auto newline = new AssDialogue; newline->Start = cur->End; newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt(); newline->Style = cur->Style; @@ -91,7 +91,7 @@ struct grid_line_prev : public Command { STR_DISP("Previous Line") STR_HELP("Move to the previous line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->selectionController->PrevLine(); } }; @@ -102,7 +102,7 @@ struct grid_sort_actor : public Command { STR_DISP("Actor Name") STR_HELP("Sort all subtitles by their actor names") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompActor); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -111,7 +111,7 @@ struct grid_sort_actor : public Command { struct validate_sel_multiple : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() > 1; } }; @@ -122,7 +122,7 @@ struct grid_sort_actor_selected : public validate_sel_multiple { STR_DISP("Actor Name") STR_HELP("Sort selected subtitles by their actor names") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompActor, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -134,7 +134,7 @@ struct grid_sort_effect : public Command { STR_DISP("Effect") STR_HELP("Sort all subtitles by their effects") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompEffect); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -146,7 +146,7 @@ struct grid_sort_effect_selected : public validate_sel_multiple { STR_DISP("Effect") STR_HELP("Sort selected subtitles by their effects") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompEffect, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -158,7 +158,7 @@ struct grid_sort_end : public Command { STR_DISP("End Time") STR_HELP("Sort all subtitles by their end times") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompEnd); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -170,7 +170,7 @@ struct grid_sort_end_selected : public validate_sel_multiple { STR_DISP("End Time") STR_HELP("Sort selected subtitles by their end times") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompEnd, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -182,7 +182,7 @@ struct grid_sort_layer : public Command { STR_DISP("Layer") STR_HELP("Sort all subtitles by their layer number") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompLayer); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -194,7 +194,7 @@ struct grid_sort_layer_selected : public validate_sel_multiple { STR_DISP("Layer") STR_HELP("Sort selected subtitles by their layer number") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompLayer, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -206,7 +206,7 @@ struct grid_sort_start : public Command { STR_DISP("Start Time") STR_HELP("Sort all subtitles by their start times") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -218,7 +218,7 @@ struct grid_sort_start_selected : public validate_sel_multiple { STR_DISP("Start Time") STR_HELP("Sort selected subtitles by their start times") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompStart, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -230,7 +230,7 @@ struct grid_sort_style : public Command { STR_DISP("Style Name") STR_HELP("Sort all subtitles by their style names") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompStyle); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -242,7 +242,7 @@ struct grid_sort_style_selected : public validate_sel_multiple { STR_DISP("Style Name") STR_HELP("Sort selected subtitles by their style names") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->ass->Sort(AssFile::CompStyle, c->selectionController->GetSelectedSet()); c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); } @@ -254,7 +254,7 @@ struct grid_tag_cycle_hiding : public Command { STR_DISP("Cycle Tag Hiding Mode") STR_HELP("Cycle through tag hiding modes") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { int tagMode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt(); // Cycle to next @@ -279,11 +279,11 @@ struct grid_tags_hide : public Command { STR_HELP("Hide override tags in the subtitle grid") CMD_TYPE(COMMAND_RADIO) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 2; } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(2); } }; @@ -295,11 +295,11 @@ struct grid_tags_show : public Command { STR_HELP("Show full override tags in the subtitle grid") CMD_TYPE(COMMAND_RADIO) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 0; } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(0); } }; @@ -311,11 +311,11 @@ struct grid_tags_simplify : public Command { STR_HELP("Replace override tags in the subtitle grid with a simplified placeholder") CMD_TYPE(COMMAND_RADIO) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 1; } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(1); } }; @@ -348,11 +348,11 @@ struct grid_move_up : public Command { STR_HELP("Move the selected lines up one row") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() != 0; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (move_one(c->ass->Line.begin(), c->ass->Line.end(), c->selectionController->GetSelectedSet(), 1)) c->ass->Commit(_("move lines"), AssFile::COMMIT_ORDER); } @@ -365,11 +365,11 @@ struct grid_move_down : public Command { STR_HELP("Move the selected lines down one row") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() != 0; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (move_one(--c->ass->Line.end(), c->ass->Line.begin(), c->selectionController->GetSelectedSet(), -1)) c->ass->Commit(_("move lines"), AssFile::COMMIT_ORDER); } @@ -382,11 +382,11 @@ struct grid_swap : public Command { STR_HELP("Swap the two selected lines") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->selectionController->GetSelectedSet().size() == 2; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SubtitleSelection sel = c->selectionController->GetSelectedSet(); if (sel.size() == 2) { (*sel.begin())->swap_nodes(**sel.rbegin()); diff --git a/aegisub/src/command/help.cpp b/aegisub/src/command/help.cpp index 9c9280697..d645225d3 100644 --- a/aegisub/src/command/help.cpp +++ b/aegisub/src/command/help.cpp @@ -50,11 +50,11 @@ struct help_bugs : public Command { STR_DISP("Bug Tracker") STR_HELP("Visit Aegisub's bug tracker to report bugs and request new features") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (wxGetMouseState().CmdDown()) { if (wxGetMouseState().ShiftDown()) { wxMessageBox("Now crashing with an access violation..."); - for (char *foo = (char*)0;;) *foo++ = 42; + for (char *foo = (char*)nullptr;;) *foo++ = 42; } else { wxMessageBox("Now crashing with an unhandled exception..."); throw c->parent; @@ -70,7 +70,7 @@ struct help_contents : public Command { STR_DISP("Contents") STR_HELP("Help topics") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { HelpButton::OpenPage("Main"); } }; @@ -81,7 +81,7 @@ struct help_forums : public Command { STR_DISP("Forums") STR_HELP("Visit Aegisub's forums") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { wxLaunchDefaultBrowser("http://forum.aegisub.org/", wxBROWSER_NEW_WINDOW); } }; @@ -92,7 +92,7 @@ struct help_irc : public Command { STR_DISP("IRC Channel") STR_HELP("Visit Aegisub's official IRC channel") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { wxLaunchDefaultBrowser("irc://irc.rizon.net/aegisub", wxBROWSER_NEW_WINDOW); } }; @@ -103,7 +103,7 @@ struct help_video : public Command { STR_DISP("Visual Typesetting") STR_HELP("Open the manual page for Visual Typesetting") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { HelpButton::OpenPage("Visual Typesetting"); } }; @@ -114,7 +114,7 @@ struct help_website : public Command { STR_DISP("Website") STR_HELP("Visit Aegisub's official website") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { wxLaunchDefaultBrowser("http://www.aegisub.org/", wxBROWSER_NEW_WINDOW); } }; diff --git a/aegisub/src/command/icon.cpp b/aegisub/src/command/icon.cpp index 2522c5c89..552e5954e 100644 --- a/aegisub/src/command/icon.cpp +++ b/aegisub/src/command/icon.cpp @@ -59,7 +59,7 @@ wxBitmap const& get(std::string const& name, const int size) { void icon_init() { // Seems that WX doesn't install the handlers early enough for our use. - wxPNGHandler *handler = new wxPNGHandler(); + auto handler = new wxPNGHandler(); wxImage::AddHandler(handler); LOG_D("icon/init") << "Generating 24x24, 16x16 icons"; diff --git a/aegisub/src/command/keyframe.cpp b/aegisub/src/command/keyframe.cpp index 30cab8f11..523c306cf 100644 --- a/aegisub/src/command/keyframe.cpp +++ b/aegisub/src/command/keyframe.cpp @@ -50,11 +50,11 @@ struct keyframe_close : public Command { STR_HELP("Discard the currently loaded keyframes and use those from the video, if any") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->OverKeyFramesLoaded(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->CloseKeyframes(); } }; @@ -65,7 +65,7 @@ struct keyframe_open : public Command { STR_DISP("Open Keyframes") STR_HELP("Open a keyframe list file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto filename = OpenFileSelector( _("Open keyframes file"), "Path/Last/Keyframes", "" ,".txt", @@ -84,11 +84,11 @@ struct keyframe_save : public Command { STR_HELP("Save the current list of keyframes to a file") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->KeyFramesLoaded(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto filename = SaveFileSelector(_("Save keyframes file"), "Path/Last/Keyframes", "", "*.key.txt", "Text files (*.txt)|*.txt", c->parent); if (!filename.empty()) c->videoController->SaveKeyframes(filename); diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index c096db04f..6ea5729b6 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -63,14 +63,14 @@ namespace { struct validate_nonempty_selection : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return !c->selectionController->GetSelectedSet().empty(); } }; struct validate_nonempty_selection_video_loaded : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded() && !c->selectionController->GetSelectedSet().empty(); } }; @@ -81,7 +81,7 @@ struct subtitle_attachment : public Command { STR_DISP("Attachments") STR_HELP("Open the attachment manager dialog") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogAttachments(c->parent, c->ass).ShowModal(); } @@ -93,7 +93,7 @@ struct subtitle_find : public Command { STR_DISP("Find") STR_HELP("Search for text the in subtitles") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogSearchReplace::Show(c, false); } @@ -105,7 +105,7 @@ struct subtitle_find_next : public Command { STR_DISP("Find Next") STR_HELP("Find next match of last search") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); if (!c->search->FindNext()) DialogSearchReplace::Show(c, false); @@ -113,7 +113,7 @@ struct subtitle_find_next : public Command { }; static void insert_subtitle_at_video(agi::Context *c, bool after) { - AssDialogue *def = new AssDialogue; + auto def = new AssDialogue; int video_ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START); def->Start = video_ms; def->End = video_ms + OPT_GET("Timing/Default Duration")->GetInt(); @@ -136,10 +136,10 @@ struct subtitle_insert_after : public validate_nonempty_selection { STR_DISP("After Current") STR_HELP("Insert a new line after the current one") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *active_line = c->selectionController->GetActiveLine(); - AssDialogue *new_line = new AssDialogue; + auto new_line = new AssDialogue; new_line->Style = active_line->Style; new_line->Start = active_line->End; new_line->End = new_line->Start + OPT_GET("Timing/Default Duration")->GetInt(); @@ -172,7 +172,7 @@ struct subtitle_insert_after_videotime : public validate_nonempty_selection_vide STR_DISP("After Current, at Video Time") STR_HELP("Insert a new line after the current one, starting at video time") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { insert_subtitle_at_video(c, true); } }; @@ -183,10 +183,10 @@ struct subtitle_insert_before : public validate_nonempty_selection { STR_DISP("Before Current") STR_HELP("Insert a new line before the current one") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *active_line = c->selectionController->GetActiveLine(); - AssDialogue *new_line = new AssDialogue; + auto new_line = new AssDialogue; new_line->Style = active_line->Style; new_line->End = active_line->Start; new_line->Start = new_line->End - OPT_GET("Timing/Default Duration")->GetInt(); @@ -216,7 +216,7 @@ struct subtitle_insert_before_videotime : public validate_nonempty_selection_vid STR_DISP("Before Current, at Video Time") STR_HELP("Insert a new line before the current one, starting at video time") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { insert_subtitle_at_video(c, false); } }; @@ -227,7 +227,7 @@ struct subtitle_new : public Command { STR_DISP("New Subtitles") STR_HELP("New subtitles") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->subsController->TryToClose() != wxCANCEL) c->subsController->Close(); } @@ -239,7 +239,7 @@ struct subtitle_open : public Command { STR_DISP("Open Subtitles") STR_HELP("Open a subtitles file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->subsController->TryToClose() == wxCANCEL) return; auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent); if (!filename.empty()) @@ -253,7 +253,7 @@ struct subtitle_open_autosave : public Command { STR_DISP("Open Autosaved Subtitles") STR_HELP("Open a previous version of a file which was autosaved by Aegisub") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->subsController->TryToClose() == wxCANCEL) return; DialogAutosave dialog(c->parent); if (dialog.ShowModal() == wxID_OK) @@ -267,7 +267,7 @@ struct subtitle_open_charset : public Command { STR_DISP("Open Subtitles with Charset") STR_HELP("Open a subtitles file with a specific file encoding") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->subsController->TryToClose() == wxCANCEL) return; auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent); @@ -287,12 +287,12 @@ struct subtitle_open_video : public Command { STR_HELP("Open the subtitles from the current video file") CMD_TYPE(COMMAND_VALIDATE) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->subsController->TryToClose() == wxCANCEL) return; c->subsController->Load(c->videoController->GetVideoName(), "binary"); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded() && c->videoController->HasSubtitles(); } }; @@ -303,7 +303,7 @@ struct subtitle_properties : public Command { STR_DISP("Properties") STR_HELP("Open script properties window") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogProperties(c).ShowModal(); } @@ -339,11 +339,11 @@ struct subtitle_save : public Command { STR_HELP("Save the current subtitles") CMD_TYPE(COMMAND_VALIDATE) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { save_subtitles(c, c->subsController->CanSave() ? c->subsController->Filename() : ""); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->subsController->IsModified(); } }; @@ -354,7 +354,7 @@ struct subtitle_save_as : public Command { STR_DISP("Save Subtitles as") STR_HELP("Save subtitles with another name") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { save_subtitles(c, ""); } }; @@ -365,7 +365,7 @@ struct subtitle_select_all : public Command { STR_DISP("Select All") STR_HELP("Select all dialogue lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SubtitleSelection sel; transform(c->ass->Line.begin(), c->ass->Line.end(), inserter(sel, sel.begin()), cast()); @@ -381,7 +381,7 @@ struct subtitle_select_visible : public Command { STR_HELP("Select all dialogue lines that visible on the current video frame") CMD_TYPE(COMMAND_VALIDATE) - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (!c->videoController->IsLoaded()) return; c->videoController->Stop(); @@ -403,7 +403,7 @@ struct subtitle_select_visible : public Command { c->selectionController->SetSelectedSet(new_selection); } - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded(); } }; @@ -414,7 +414,7 @@ struct subtitle_spellcheck : public Command { STR_DISP("Spell Checker") STR_HELP("Open spell checker") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->dialog->Show(c); } diff --git a/aegisub/src/command/time.cpp b/aegisub/src/command/time.cpp index e3cc11bbf..747634aa4 100644 --- a/aegisub/src/command/time.cpp +++ b/aegisub/src/command/time.cpp @@ -54,14 +54,14 @@ namespace { struct validate_video_loaded : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded(); } }; struct validate_adjoinable : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { SubtitleSelection sel = c->selectionController->GetSelectedSet(); if (sel.size() < 2) return !sel.empty(); @@ -112,7 +112,7 @@ struct time_continuous_end : public validate_adjoinable { STR_DISP("Change End") STR_HELP("Change end times of lines to the next line's start time") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { adjoin_lines(c, false); } }; @@ -123,7 +123,7 @@ struct time_continuous_start : public validate_adjoinable { STR_DISP("Change Start") STR_HELP("Change start times of lines to the previous line's end time") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { adjoin_lines(c, true); } }; @@ -134,7 +134,7 @@ struct time_frame_current : public validate_video_loaded { STR_DISP("Shift to Current Frame") STR_HELP("Shift selection so that the active line starts at current frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (!c->videoController->IsLoaded()) return; SubtitleSelection const& sel = c->selectionController->GetSelectedSet(); @@ -160,7 +160,7 @@ struct time_shift : public Command { STR_DISP("Shift Times") STR_HELP("Shift subtitles by time or frames") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -189,7 +189,7 @@ struct time_snap_end_video : public validate_video_loaded { STR_DISP("Snap End to Video") STR_HELP("Set end of selected subtitles to current video frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { snap_subs_video(c, false); } }; @@ -200,7 +200,7 @@ struct time_snap_scene : public validate_video_loaded { STR_DISP("Snap to Scene") STR_HELP("Set start and end of subtitles to the keyframes around current video frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { VideoContext *con = c->videoController; if (!con->IsLoaded() || !con->KeyFramesLoaded()) return; @@ -244,7 +244,7 @@ struct time_add_lead_both : public Command { STR_MENU("Add lead in and out") STR_DISP("Add lead in and out") STR_HELP("Add both lead in and out to the selected lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (AudioTimingController *tc = c->audioController->GetTimingController()) { tc->AddLeadIn(); tc->AddLeadOut(); @@ -257,7 +257,7 @@ struct time_add_lead_in : public Command { STR_MENU("Add lead in") STR_DISP("Add lead in") STR_HELP("Add the lead in time to the selected lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->AddLeadIn(); } @@ -268,7 +268,7 @@ struct time_add_lead_out : public Command { STR_MENU("Add lead out") STR_DISP("Add lead out") STR_HELP("Add the lead out time to the selected lines") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->AddLeadOut(); } @@ -279,7 +279,7 @@ struct time_length_increase : public Command { STR_MENU("Increase length") STR_DISP("Increase length") STR_HELP("Increase the length of the current timing unit") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyLength(1, false); } @@ -290,7 +290,7 @@ struct time_length_increase_shift : public Command { STR_MENU("Increase length and shift") STR_DISP("Increase length and shift") STR_HELP("Increase the length of the current timing unit and shift the following items") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyLength(1, true); } @@ -301,7 +301,7 @@ struct time_length_decrease : public Command { STR_MENU("Decrease length") STR_DISP("Decrease length") STR_HELP("Decrease the length of the current timing unit") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyLength(-1, false); } @@ -312,7 +312,7 @@ struct time_length_decrease_shift : public Command { STR_MENU("Decrease length and shift") STR_DISP("Decrease length and shift") STR_HELP("Decrease the length of the current timing unit and shift the following items") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyLength(-1, true); } @@ -323,7 +323,7 @@ struct time_start_increase : public Command { STR_MENU("Shift start time forward") STR_DISP("Shift start time forward") STR_HELP("Shift the start time of the current timing unit forward") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyStart(1); } @@ -334,7 +334,7 @@ struct time_start_decrease : public Command { STR_MENU("Shift start time backward") STR_DISP("Shift start time backward") STR_HELP("Shift the start time of the current timing unit backward") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->ModifyStart(-1); } @@ -346,7 +346,7 @@ struct time_snap_start_video : public validate_video_loaded { STR_DISP("Snap Start to Video") STR_HELP("Set start of selected subtitles to current video frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { snap_subs_video(c, true); } }; @@ -356,7 +356,7 @@ struct time_next : public Command { STR_MENU("Next Line") STR_DISP("Next Line") STR_HELP("Next line or syllable") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->Next(AudioTimingController::TIMING_UNIT); } @@ -367,7 +367,7 @@ struct time_prev : public Command { STR_MENU("Previous Line") STR_DISP("Previous Line") STR_HELP("Previous line or syllable") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (c->audioController->GetTimingController()) c->audioController->GetTimingController()->Prev(); } diff --git a/aegisub/src/command/timecode.cpp b/aegisub/src/command/timecode.cpp index 1de8c85dd..b45ef053d 100644 --- a/aegisub/src/command/timecode.cpp +++ b/aegisub/src/command/timecode.cpp @@ -50,11 +50,11 @@ struct timecode_close : public Command { STR_HELP("Close the currently open timecodes file") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->OverTimecodesLoaded(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->CloseTimecodes(); } }; @@ -65,7 +65,7 @@ struct timecode_open : public Command { STR_DISP("Open Timecodes File") STR_HELP("Open a VFR timecodes v1 or v2 file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*"; auto filename = OpenFileSelector(_("Open Timecodes File"), "Path/Last/Timecodes", "", "", str, c->parent); if (!filename.empty()) @@ -80,11 +80,11 @@ struct timecode_save : public Command { STR_HELP("Save a VFR timecodes v2 file") CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->TimecodesLoaded(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*"; auto filename = SaveFileSelector(_("Save Timecodes File"), "Path/Last/Timecodes", "", "", str, c->parent); if (!filename.empty()) diff --git a/aegisub/src/command/tool.cpp b/aegisub/src/command/tool.cpp index e89cd1050..96a097e15 100644 --- a/aegisub/src/command/tool.cpp +++ b/aegisub/src/command/tool.cpp @@ -65,7 +65,7 @@ struct tool_assdraw : public Command { STR_DISP("ASSDraw3") STR_HELP("Launch the ASSDraw3 tool for vector drawing") - void operator()(agi::Context *) { + void operator()(agi::Context *) override { wxExecute("\"" + config::path->Decode("?data/ASSDraw3.exe").wstring() + "\""); } }; @@ -76,7 +76,7 @@ struct tool_export : public Command { STR_DISP("Export Subtitles") STR_HELP("Save a copy of subtitles in a different format or with processing applied to it") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogExport(c).ShowModal(); } @@ -88,7 +88,7 @@ struct tool_font_collector : public Command { STR_DISP("Fonts Collector") STR_HELP("Open fonts collector") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -99,7 +99,7 @@ struct tool_line_select : public Command { STR_DISP("Select Lines") STR_HELP("Select lines based on defined criteria") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -110,7 +110,7 @@ struct tool_resampleres : public Command { STR_DISP("Resample Resolution") STR_HELP("Resample subtitles to maintain their current appearance at a different script resolution") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); ResampleSettings settings; if (DialogResample(c, settings).ShowModal() == wxID_OK) @@ -124,7 +124,7 @@ struct tool_style_assistant : public Command { STR_DISP("Styling Assistant") STR_HELP("Open styling assistant") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -132,7 +132,7 @@ struct tool_style_assistant : public Command { struct tool_styling_assistant_validator : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return !!c->dialog->Get(); } }; @@ -143,7 +143,7 @@ struct tool_styling_assistant_commit : public tool_styling_assistant_validator { STR_DISP("Accept changes") STR_HELP("Commit changes and move to the next line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->Commit(true); } }; @@ -154,7 +154,7 @@ struct tool_styling_assistant_preview : public tool_styling_assistant_validator STR_DISP("Preview changes") STR_HELP("Commit changes and stay on the current line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->Commit(false); } }; @@ -165,7 +165,7 @@ struct tool_style_manager : public Command { STR_DISP("Styles Manager") STR_HELP("Open the styles manager") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Show(c); } }; @@ -176,7 +176,7 @@ struct tool_time_kanji : public Command { STR_DISP("Kanji Timer") STR_HELP("Open the Kanji timer copier") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { DialogKanjiTimer(c).ShowModal(); } }; @@ -187,7 +187,7 @@ struct tool_time_postprocess : public Command { STR_DISP("Timing Post-Processor") STR_HELP("Post-process the subtitle timing to add lead-ins and lead-outs, snap timing to scene changes, etc.") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { DialogTimingProcessor(c).ShowModal(); } }; @@ -198,7 +198,7 @@ struct tool_translation_assistant : public Command { STR_DISP("Translation Assistant") STR_HELP("Open translation assistant") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); try { c->dialog->ShowModal(c); @@ -212,7 +212,7 @@ struct tool_translation_assistant : public Command { struct tool_translation_assistant_validator : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return !!c->dialog->Get(); } }; @@ -223,7 +223,7 @@ struct tool_translation_assistant_commit : public tool_translation_assistant_val STR_DISP("Accept changes") STR_HELP("Commit changes and move to the next line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->Commit(true); } }; @@ -234,7 +234,7 @@ struct tool_translation_assistant_preview : public tool_translation_assistant_va STR_DISP("Preview changes") STR_HELP("Commit changes and stay on the current line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->Commit(false); } }; @@ -245,7 +245,7 @@ struct tool_translation_assistant_next : public tool_translation_assistant_valid STR_DISP("Next Line") STR_HELP("Move to the next line without committing changes") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->NextBlock(); } }; @@ -256,7 +256,7 @@ struct tool_translation_assistant_prev : public tool_translation_assistant_valid STR_DISP("Previous Line") STR_HELP("Move to the previous line without committing changes") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->PrevBlock(); } }; @@ -268,7 +268,7 @@ struct tool_translation_assistant_insert : public tool_translation_assistant_val STR_DISP("Insert Original") STR_HELP("Insert the untranslated text") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->dialog->Get()->InsertOriginal(); } }; diff --git a/aegisub/src/command/video.cpp b/aegisub/src/command/video.cpp index 0a96945ca..07715f5c9 100644 --- a/aegisub/src/command/video.cpp +++ b/aegisub/src/command/video.cpp @@ -72,14 +72,14 @@ namespace { struct validator_video_loaded : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded(); } }; struct validator_video_attached : public Command { CMD_TYPE(COMMAND_VALIDATE) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded() && !c->dialog->Get(); } }; @@ -91,11 +91,11 @@ struct video_aspect_cinematic : public validator_video_loaded { STR_HELP("Force video to 2.35 aspect ratio") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoController->GetAspectRatioType() == AspectRatio::Cinematic; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoController->SetAspectRatio(AspectRatio::Cinematic); wxGetApp().frame->SetDisplayMode(1,-1); @@ -109,11 +109,11 @@ struct video_aspect_custom : public validator_video_loaded { STR_HELP("Force video to a custom aspect ratio") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoController->GetAspectRatioType() == AspectRatio::Custom; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); std::string value = from_wx(wxGetTextFromUser( @@ -152,11 +152,11 @@ struct video_aspect_default : public validator_video_loaded { STR_HELP("Use video's original aspect ratio") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoController->GetAspectRatioType() == AspectRatio::Default; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoController->SetAspectRatio(AspectRatio::Default); wxGetApp().frame->SetDisplayMode(1,-1); @@ -170,11 +170,11 @@ struct video_aspect_full : public validator_video_loaded { STR_HELP("Force video to 4:3 aspect ratio") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoController->GetAspectRatioType() == AspectRatio::Fullscreen; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoController->SetAspectRatio(AspectRatio::Fullscreen); wxGetApp().frame->SetDisplayMode(1,-1); @@ -188,11 +188,11 @@ struct video_aspect_wide : public validator_video_loaded { STR_HELP("Force video to 16:9 aspect ratio") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoController->GetAspectRatioType() == AspectRatio::Widescreen; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoController->SetAspectRatio(AspectRatio::Widescreen); wxGetApp().frame->SetDisplayMode(1,-1); @@ -205,7 +205,7 @@ struct video_close : public validator_video_loaded { STR_DISP("Close Video") STR_HELP("Close the currently open video file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->SetVideo(""); } }; @@ -216,7 +216,7 @@ struct video_copy_coordinates : public validator_video_loaded { STR_DISP("Copy coordinates to Clipboard") STR_HELP("Copy the current coordinates of the mouse over the video to the clipboard") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SetClipboard(c->videoDisplay->GetMousePosition().Str()); } }; @@ -227,7 +227,7 @@ struct video_cycle_subtitles_provider : public cmd::Command { STR_DISP("Cycle active subtitles provider") STR_HELP("Cycle through the available subtitles providers") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto providers = SubtitlesProviderFactory::GetClasses(); if (providers.empty()) return; @@ -247,11 +247,11 @@ struct video_detach : public validator_video_loaded { STR_HELP("Detach the video display from the main window, displaying it in a separate Window") CMD_TYPE(COMMAND_VALIDATE | COMMAND_TOGGLE) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return !!c->dialog->Get(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (DialogDetachedVideo *d = c->dialog->Get()) d->Close(); else @@ -265,7 +265,7 @@ struct video_details : public validator_video_loaded { STR_DISP("Show Video Details") STR_HELP("Show video details") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); DialogVideoDetails(c).ShowModal(); } @@ -277,7 +277,7 @@ struct video_focus_seek : public validator_video_loaded { STR_DISP("Toggle video slider focus") STR_HELP("Toggle focus between the video slider and the previous thing to have focus") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { wxWindow *curFocus = wxWindow::FindFocus(); if (curFocus == c->videoSlider) { if (c->previousFocus) c->previousFocus->SetFocus(); @@ -295,7 +295,7 @@ struct video_frame_copy : public validator_video_loaded { STR_DISP("Copy image to Clipboard") STR_HELP("Copy the currently displayed frame to the clipboard") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SetClipboard(wxBitmap(GetImage(*c->videoController->GetFrame(c->videoController->GetFrameN())), 24)); } }; @@ -306,7 +306,7 @@ struct video_frame_copy_raw : public validator_video_loaded { STR_DISP("Copy image to Clipboard (no subtitles)") STR_HELP("Copy the currently displayed frame to the clipboard, without the subtitles") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { SetClipboard(wxBitmap(GetImage(*c->videoController->GetFrame(c->videoController->GetFrameN(), true)), 24)); } }; @@ -317,7 +317,7 @@ struct video_frame_next : public validator_video_loaded { STR_DISP("Next Frame") STR_HELP("Seek to the next frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->NextFrame(); } }; @@ -328,7 +328,7 @@ struct video_frame_next_boundary : public validator_video_loaded { STR_DISP("Next Boundary") STR_HELP("Seek to the next beginning or end of a subtitle") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *active_line = c->selectionController->GetActiveLine(); if (!active_line) return; @@ -357,7 +357,7 @@ struct video_frame_next_keyframe : public validator_video_loaded { STR_DISP("Next Keyframe") STR_HELP("Seek to the next keyframe") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto const& kf = c->videoController->GetKeyFrames(); auto pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN() + 1); @@ -371,7 +371,7 @@ struct video_frame_next_large : public validator_video_loaded { STR_DISP("Fast jump forward") STR_HELP("Fast jump forward") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->JumpToFrame( c->videoController->GetFrameN() + OPT_GET("Video/Slider/Fast Jump Step")->GetInt()); @@ -384,7 +384,7 @@ struct video_frame_prev : public validator_video_loaded { STR_DISP("Previous Frame") STR_HELP("Seek to the previous frame") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->PrevFrame(); } }; @@ -395,7 +395,7 @@ struct video_frame_prev_boundary : public validator_video_loaded { STR_DISP("Previous Boundary") STR_HELP("Seek to the previous beginning or end of a subtitle") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { AssDialogue *active_line = c->selectionController->GetActiveLine(); if (!active_line) return; @@ -424,7 +424,7 @@ struct video_frame_prev_keyframe : public validator_video_loaded { STR_DISP("Previous Keyframe") STR_HELP("Seek to the previous keyframe") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto const& kf = c->videoController->GetKeyFrames(); if (kf.empty()) { c->videoController->JumpToFrame(0); @@ -446,7 +446,7 @@ struct video_frame_prev_large : public validator_video_loaded { STR_DISP("Fast jump backwards") STR_HELP("Fast jump backwards") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->JumpToFrame( c->videoController->GetFrameN() - OPT_GET("Video/Slider/Fast Jump Step")->GetInt()); @@ -497,7 +497,7 @@ struct video_frame_save : public validator_video_loaded { STR_DISP("Save PNG snapshot") STR_HELP("Save the currently displayed frame to a PNG file in the video's directory") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { save_snapshot(c, false); } }; @@ -508,7 +508,7 @@ struct video_frame_save_raw : public validator_video_loaded { STR_DISP("Save PNG snapshot (no subtitles)") STR_HELP("Save the currently displayed frame without the subtitles to a PNG file in the video's directory") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { save_snapshot(c, true); } }; @@ -519,7 +519,7 @@ struct video_jump : public validator_video_loaded { STR_DISP("Jump to") STR_HELP("Jump to frame or time") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); if (c->videoController->IsLoaded()) { DialogJumpTo(c).ShowModal(); @@ -534,7 +534,7 @@ struct video_jump_end : public validator_video_loaded { STR_DISP("Jump Video to End") STR_HELP("Jump the video to the end frame of current subtitle") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (AssDialogue *active_line = c->selectionController->GetActiveLine()) { c->videoController->JumpToTime(active_line->End, agi::vfr::END); } @@ -547,7 +547,7 @@ struct video_jump_start : public validator_video_loaded { STR_DISP("Jump Video to Start") STR_HELP("Jump the video to the start frame of current subtitle") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { if (AssDialogue *active_line = c->selectionController->GetActiveLine()) c->videoController->JumpToTime(active_line->Start); } @@ -559,7 +559,7 @@ struct video_open : public Command { STR_DISP("Open Video") STR_HELP("Open a video file") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { auto str = _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts,*.y4m,*.yuv)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts;*.y4m;*.yuv|" + _("All Files") + " (*.*)|*.*"; auto filename = OpenFileSelector(_("Open video file"), "Path/Last/Video", "", "", str, c->parent); @@ -574,7 +574,7 @@ struct video_open_dummy : public Command { STR_DISP("Use Dummy Video") STR_HELP("Open a placeholder video clip with solid color") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { std::string fn = DialogDummyVideo::CreateDummyVideo(c->parent); if (!fn.empty()) c->videoController->SetVideo(fn); @@ -588,11 +588,11 @@ struct video_opt_autoscroll : public Command { STR_HELP("Toggle automatically seeking video to the start time of selected lines") CMD_TYPE(COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Video/Subtitle Sync")->GetBool(); } - void operator()(agi::Context *) { + void operator()(agi::Context *) override { OPT_SET("Video/Subtitle Sync")->SetBool(!OPT_GET("Video/Subtitle Sync")->GetBool()); } }; @@ -603,7 +603,7 @@ struct video_play : public validator_video_loaded { STR_DISP("Play") STR_HELP("Play video starting on this position") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Play(); } }; @@ -614,7 +614,7 @@ struct video_play_line : public validator_video_loaded { STR_DISP("Play line") STR_HELP("Play current line") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->PlayLine(); } }; @@ -626,11 +626,11 @@ struct video_show_overscan : public validator_video_loaded { STR_HELP("Show a mask over the video, indicating areas that might get cropped off by overscan on televisions") CMD_TYPE(COMMAND_VALIDATE | COMMAND_TOGGLE) - bool IsActive(const agi::Context *) { + bool IsActive(const agi::Context *) override { return OPT_GET("Video/Overscan Mask")->GetBool(); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { OPT_SET("Video/Overscan Mask")->SetBool(!OPT_GET("Video/Overscan Mask")->GetBool()); c->videoDisplay->Render(); } @@ -644,11 +644,11 @@ public: STR_HELP("Set zoom to 100%") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoDisplay->GetZoom() == 1.; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoDisplay->SetZoom(1.); } @@ -661,7 +661,7 @@ public: STR_DISP("Stop video") STR_HELP("Stop video playback") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); } }; @@ -674,11 +674,11 @@ public: STR_HELP("Set zoom to 200%") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoDisplay->GetZoom() == 2.; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoDisplay->SetZoom(2.); } @@ -692,11 +692,11 @@ public: STR_HELP("Set zoom to 50%") CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoDisplay->GetZoom() == .5; } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoController->Stop(); c->videoDisplay->SetZoom(.5); } @@ -708,7 +708,7 @@ struct video_zoom_in : public validator_video_attached { STR_DISP("Zoom In") STR_HELP("Zoom video in") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoDisplay->SetZoom(c->videoDisplay->GetZoom() + .125); } }; @@ -719,7 +719,7 @@ struct video_zoom_out : public validator_video_attached { STR_DISP("Zoom Out") STR_HELP("Zoom video out") - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoDisplay->SetZoom(c->videoDisplay->GetZoom() - .125); } }; diff --git a/aegisub/src/command/vis_tool.cpp b/aegisub/src/command/vis_tool.cpp index 9c331b39f..b50c9bbf4 100644 --- a/aegisub/src/command/vis_tool.cpp +++ b/aegisub/src/command/vis_tool.cpp @@ -39,15 +39,15 @@ namespace { struct visual_tool_command : public Command { CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO) - bool Validate(const agi::Context *c) { + bool Validate(const agi::Context *c) override { return c->videoController->IsLoaded(); } - bool IsActive(const agi::Context *c) { + bool IsActive(const agi::Context *c) override { return c->videoDisplay->ToolIsType(typeid(T)); } - void operator()(agi::Context *c) { + void operator()(agi::Context *c) override { c->videoDisplay->SetTool(agi::util::make_unique(c->videoDisplay, c)); } }; diff --git a/aegisub/src/dialog_automation.cpp b/aegisub/src/dialog_automation.cpp index a2a9ce25a..1fe33ed73 100644 --- a/aegisub/src/dialog_automation.cpp +++ b/aegisub/src/dialog_automation.cpp @@ -240,7 +240,7 @@ static wxString form_to_str(const SubtitleFormat* f) { void DialogAutomation::OnInfo(wxCommandEvent &) { int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - ExtraScriptInfo *ei = i >= 0 ? &script_info[list->GetItemData(i)] : 0; + ExtraScriptInfo *ei = i >= 0 ? &script_info[list->GetItemData(i)] : nullptr; wxArrayString info; std::back_insert_iterator append_info(info); diff --git a/aegisub/src/dialog_autosave.h b/aegisub/src/dialog_autosave.h index 3d0187ba0..6be7932a6 100644 --- a/aegisub/src/dialog_autosave.h +++ b/aegisub/src/dialog_autosave.h @@ -29,8 +29,8 @@ class DialogAutosave : public wxDialog { wxString filename; wxDateTime date; wxString display; - Version(wxString const& filename, wxDateTime const& date, wxString const& display) - : filename(filename), date(date), display(display) { } + Version(wxString const& filename, wxDateTime date, wxString const& display) + : filename(filename), date(std::move(date)), display(display) { } }; struct AutosaveFile { diff --git a/aegisub/src/dialog_colorpicker.cpp b/aegisub/src/dialog_colorpicker.cpp index e5674f6fe..2db6a9f83 100644 --- a/aegisub/src/dialog_colorpicker.cpp +++ b/aegisub/src/dialog_colorpicker.cpp @@ -195,14 +195,14 @@ class ColorPickerSpectrum : public wxControl { } } - bool AcceptsFocusFromKeyboard() const { return false; } + bool AcceptsFocusFromKeyboard() const override { return false; } public: ColorPickerSpectrum(wxWindow *parent, PickerDirection direction, wxSize size) : wxControl(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE) , x(-1) , y(-1) - , background(0) + , background(nullptr) , direction(direction) { size.x += 2; @@ -295,7 +295,7 @@ class ColorPickerRecent : public wxStaticBitmap { Refresh(false); } - bool AcceptsFocusFromKeyboard() const { return false; } + bool AcceptsFocusFromKeyboard() const override { return false; } public: ColorPickerRecent(wxWindow *parent, int cols, int rows, int cellsize) @@ -365,7 +365,7 @@ class ColorPickerScreenDropper : public wxControl { wxPaintDC(this).DrawBitmap(capture, 0, 0); } - bool AcceptsFocusFromKeyboard() const { return false; } + bool AcceptsFocusFromKeyboard() const override { return false; } public: ColorPickerScreenDropper(wxWindow *parent, int resx, int resy, int magnification) @@ -548,7 +548,7 @@ static wxBitmap make_slider(Func func) { DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, std::function callback, bool alpha) : wxDialog(parent, -1, _("Select Color")) -, callback(callback) +, callback(std::move(callback)) { // generate spectrum slider bar images for (int i = 0; i < 3; ++i) { @@ -576,18 +576,18 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, wxSizer *hsl_box = new wxStaticBoxSizer(wxVERTICAL, this, _("HSL color")); wxSizer *hsv_box = new wxStaticBoxSizer(wxVERTICAL, this, _("HSV color")); - for (int i = 0; i < 3; ++i) - rgb_input[i] = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); + for (auto& elem : rgb_input) + elem = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); ass_input = new wxTextCtrl(this, -1, "", wxDefaultPosition, colorinput_size); html_input = new wxTextCtrl(this, -1, "", wxDefaultPosition, colorinput_size); alpha_input = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); - for (int i = 0; i < 3; ++i) - hsl_input[i] = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); + for (auto& elem : hsl_input) + elem = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); - for (int i = 0; i < 3; ++i) - hsv_input[i] = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); + for (auto& elem : hsv_input) + elem = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); preview_box = new wxStaticBitmap(this, -1, wxBitmap(40, 40, 24), wxDefaultPosition, wxSize(40, 40), STATIC_BORDER_FLAG); recent_box = new ColorPickerRecent(this, 8, 4, 16); @@ -709,7 +709,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, template wxSizer *DialogColorPicker::MakeColorInputSizer(wxString (&labels)[N], Control *(&inputs)[N]) { - wxFlexGridSizer * sizer = new wxFlexGridSizer(2, 5, 5); + auto sizer = new wxFlexGridSizer(2, 5, 5); for (int i = 0; i < N; ++i) { sizer->Add(new wxStaticText(this, -1, labels[i]), wxSizerFlags(1).Center().Left()); sizer->Add(inputs[i]); diff --git a/aegisub/src/dialog_detached_video.cpp b/aegisub/src/dialog_detached_video.cpp index 3dc69265f..399aa43e8 100644 --- a/aegisub/src/dialog_detached_video.cpp +++ b/aegisub/src/dialog_detached_video.cpp @@ -67,7 +67,7 @@ DialogDetachedVideo::DialogDetachedVideo(agi::Context *context) old_display->Unload(); // Video area; - VideoBox *videoBox = new VideoBox(this, true, context); + auto videoBox = new VideoBox(this, true, context); context->videoDisplay->SetMinClientSize(old_display->GetClientSize()); videoBox->Layout(); diff --git a/aegisub/src/dialog_dummy_video.cpp b/aegisub/src/dialog_dummy_video.cpp index d98e86037..de1275127 100644 --- a/aegisub/src/dialog_dummy_video.cpp +++ b/aegisub/src/dialog_dummy_video.cpp @@ -73,7 +73,7 @@ wxControl *spin_ctrl(wxWindow *parent, double min, double max, double *value) { } wxComboBox *resolution_shortcuts(wxWindow *parent, int width, int height) { - wxComboBox *ctrl = new wxComboBox(parent, -1, "", wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + wxComboBox *ctrl = new wxComboBox(parent, -1, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); for (auto const& res : resolutions) { ctrl->Append(res.name); @@ -97,13 +97,13 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent) { SetIcon(GETICON(use_dummy_video_menu_16)); - wxBoxSizer *res_sizer = new wxBoxSizer(wxHORIZONTAL); + auto res_sizer = new wxBoxSizer(wxHORIZONTAL); res_sizer->Add(spin_ctrl(this, 1, 10000, &width), wxSizerFlags(1).Expand()); res_sizer->Add(new wxStaticText(this, -1, " x "), wxSizerFlags().Center()); res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand()); - wxBoxSizer *color_sizer = new wxBoxSizer(wxHORIZONTAL); - ColourButton *color_btn = new ColourButton(this, wxSize(30, 17), false, color); + auto color_sizer = new wxBoxSizer(wxHORIZONTAL); + auto color_btn = new ColourButton(this, wxSize(30, 17), false, color); color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT)); color_sizer->Add(new wxCheckBox(this, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center()); @@ -118,7 +118,7 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent) wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); btn_sizer->GetHelpButton()->Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, "Dummy Video")); - wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); + auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand()); main_sizer->Add(new wxStaticLine(this, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand()); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border()); diff --git a/aegisub/src/dialog_export_ebu3264.cpp b/aegisub/src/dialog_export_ebu3264.cpp index 9c01d0413..4a6199a4e 100644 --- a/aegisub/src/dialog_export_ebu3264.cpp +++ b/aegisub/src/dialog_export_ebu3264.cpp @@ -53,14 +53,14 @@ namespace { wxTextCtrl *GetCtrl() const { return dynamic_cast(GetWindow()); } - bool TransferToWindow() { + bool TransferToWindow() override { wxTextCtrl *ctrl = GetCtrl(); if (!ctrl) return false; ctrl->SetValue(wxString::Format("%02d:%02d:%02d:%02d", (int)value->h, (int)value->m, (int)value->s, (int)value->f)); return true; } - bool TransferFromWindow() { + bool TransferFromWindow() override { wxTextCtrl *ctrl = GetCtrl(); if (!ctrl) return false; @@ -77,7 +77,7 @@ namespace { return true; } - bool Validate(wxWindow *parent) { + bool Validate(wxWindow *parent) override { wxTextCtrl *ctrl = GetCtrl(); if (!ctrl) return false; @@ -88,7 +88,7 @@ namespace { return true; } - wxObject *Clone() const { return new TimecodeValidator(*this); } + wxObject *Clone() const override { return new TimecodeValidator(*this); } public: TimecodeValidator(EbuTimecode *target) : value(target) { assert(target); } diff --git a/aegisub/src/dialog_jumpto.cpp b/aegisub/src/dialog_jumpto.cpp index 2b02c9c6d..a93b80964 100644 --- a/aegisub/src/dialog_jumpto.cpp +++ b/aegisub/src/dialog_jumpto.cpp @@ -62,7 +62,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c) JumpFrame->SetMaxLength(std::to_string(c->videoController->GetLength() - 1).size()); JumpTime = new TimeEdit(this, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetAssFormated(), wxSize(-1,-1)); - wxGridSizer *TimesSizer = new wxGridSizer(2, 5, 5); + auto TimesSizer = new wxGridSizer(2, 5, 5); TimesSizer->Add(LabelFrame, 1, wxALIGN_CENTER_VERTICAL); TimesSizer->Add(JumpFrame, wxEXPAND); diff --git a/aegisub/src/dialog_kara_timing_copy.cpp b/aegisub/src/dialog_kara_timing_copy.cpp index b492a8cd9..d5a8d8a64 100644 --- a/aegisub/src/dialog_kara_timing_copy.cpp +++ b/aegisub/src/dialog_kara_timing_copy.cpp @@ -458,7 +458,7 @@ DialogKanjiTimer::DialogKanjiTimer(agi::Context *c) wxSizer *DisplayBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Text")); wxSizer *StylesBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Styles")); - wxFlexGridSizer *StylesGridSizer = new wxFlexGridSizer(2, 2, 6, 6); + auto StylesGridSizer = new wxFlexGridSizer(2, 2, 6, 6); wxSizer *HelpBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Shortcut Keys")); wxSizer *ButtonsBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Commands")); wxSizer *MainStackSizer = new wxBoxSizer(wxVERTICAL); @@ -510,7 +510,7 @@ DialogKanjiTimer::DialogKanjiTimer(agi::Context *c) ButtonsBoxSizer->AddStretchSpacer(1); // Button sizer - wxStdDialogButtonSizer *buttonSizer = new wxStdDialogButtonSizer(); + auto buttonSizer = new wxStdDialogButtonSizer(); buttonSizer->AddButton(new HelpButton(this,"Kanji Timer")); buttonSizer->SetAffirmativeButton(CloseKT); buttonSizer->Realize(); diff --git a/aegisub/src/dialog_log.cpp b/aegisub/src/dialog_log.cpp index e138554e3..88d4bd315 100644 --- a/aegisub/src/dialog_log.cpp +++ b/aegisub/src/dialog_log.cpp @@ -62,7 +62,7 @@ public: log(&sm); } - void log(agi::log::SinkMessage *sm) { + void log(agi::log::SinkMessage *sm) override { #ifndef _WIN32 tm tmtime; localtime_r(&sm->tv.tv_sec, &tmtime); diff --git a/aegisub/src/dialog_progress.cpp b/aegisub/src/dialog_progress.cpp index e96b7a46b..6c9552d79 100644 --- a/aegisub/src/dialog_progress.cpp +++ b/aegisub/src/dialog_progress.cpp @@ -83,23 +83,23 @@ public: { } - void SetTitle(std::string const& title) { + void SetTitle(std::string const& title) override { Main().Async([=]{ dialog->title->SetLabelText(to_wx(title)); }); } - void SetMessage(std::string const& msg) { + void SetMessage(std::string const& msg) override { Main().Async([=]{ dialog->text->SetLabelText(to_wx(msg)); }); } - void SetProgress(int64_t cur, int64_t max) { + void SetProgress(int64_t cur, int64_t max) override { Main().Async([=]{ dialog->SetProgress(mid(0, double(cur) / max * 300, 300)); }); } - void Log(std::string const& str) { + void Log(std::string const& str) override { Main().Async([=]{ dialog->pending_log += to_wx(str); }); } - bool IsCancelled() { + bool IsCancelled() override { return cancelled; } @@ -107,7 +107,7 @@ public: cancelled = true; } - void SetIndeterminate() { + void SetIndeterminate() override { Main().Async([=]{ dialog->pulse_timer.Start(1000); }); } }; diff --git a/aegisub/src/dialog_progress.h b/aegisub/src/dialog_progress.h index 2dc3dc54c..9b7c87cd5 100644 --- a/aegisub/src/dialog_progress.h +++ b/aegisub/src/dialog_progress.h @@ -64,5 +64,5 @@ public: DialogProgress(wxWindow *parent, wxString const& title="", wxString const& message=""); /// BackgroundWorker implementation - void Run(std::function task, int priority=-1); + void Run(std::function task, int priority=-1) override; }; diff --git a/aegisub/src/dialog_properties.cpp b/aegisub/src/dialog_properties.cpp index bcea20c00..b79dacc15 100644 --- a/aegisub/src/dialog_properties.cpp +++ b/aegisub/src/dialog_properties.cpp @@ -62,7 +62,7 @@ DialogProperties::DialogProperties(agi::Context *c) // Script details crap wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Script")); - wxFlexGridSizer *TopSizerGrid = new wxFlexGridSizer(0,2,5,5); + auto TopSizerGrid = new wxFlexGridSizer(0,2,5,5); AddProperty(TopSizerGrid, _("Title:"), "Title"); AddProperty(TopSizerGrid, _("Original script:"), "Original Script"); @@ -95,7 +95,7 @@ DialogProperties::DialogProperties(agi::Context *c) // Options wxSizer *optionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Options")); - wxFlexGridSizer *optionsGrid = new wxFlexGridSizer(3,2,5,5); + auto optionsGrid = new wxFlexGridSizer(3,2,5,5); wxString wrap_opts[] = { _("0: Smart wrapping, top line is wider"), _("1: End-of-line word wrapping, only \\N breaks"), diff --git a/aegisub/src/dialog_selected_choices.cpp b/aegisub/src/dialog_selected_choices.cpp index 0705534f2..afa7ca363 100644 --- a/aegisub/src/dialog_selected_choices.cpp +++ b/aegisub/src/dialog_selected_choices.cpp @@ -33,7 +33,7 @@ SelectedChoicesDialog::SelectedChoicesDialog(wxWindow *parent, wxString const& m selAll->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &SelectedChoicesDialog::SelectAll, this); selNone->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent&) { SetSelections(wxArrayInt()); }); - wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); + auto buttonSizer = new wxBoxSizer(wxHORIZONTAL); buttonSizer->Add(selAll, wxSizerFlags(0).Left()); buttonSizer->Add(selNone, wxSizerFlags(0).Right()); diff --git a/aegisub/src/dialog_selection.cpp b/aegisub/src/dialog_selection.cpp index 5d97953bc..8293a0b0d 100644 --- a/aegisub/src/dialog_selection.cpp +++ b/aegisub/src/dialog_selection.cpp @@ -98,7 +98,7 @@ wxDialog (c->parent, -1, _("Select"), wxDefaultPosition, wxDefaultSize, wxCAPTIO wxSizerFlags main_flags = wxSizerFlags().Expand().Border(); - wxRadioButton *select_matching_lines = 0; + wxRadioButton *select_matching_lines = nullptr; { wxSizer *match_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Match")); { diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index ef2152b33..4c599ba76 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -54,15 +54,15 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) : wxDialog(context->parent, -1, _("Spell Checker")) , context(context) , spellchecker(SpellCheckerFactory::GetSpellChecker()) -, start_line(0) -, active_line(0) +, start_line(nullptr) +, active_line(nullptr) , has_looped(false) { SetIcon(GETICON(spellcheck_toolbutton_16)); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); - wxFlexGridSizer *current_word_sizer = new wxFlexGridSizer(2, 5, 5); + auto current_word_sizer = new wxFlexGridSizer(2, 5, 5); main_sizer->Add(current_word_sizer, wxSizerFlags().Expand().Border(wxALL, 5)); wxSizer *bottom_sizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index b2f68c01c..d1b6c80a6 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -105,12 +105,12 @@ class StyleRenamer { } public: - StyleRenamer(agi::Context *c, std::string const& source_name, std::string const& new_name) + StyleRenamer(agi::Context *c, std::string source_name, std::string new_name) : c(c) , found_any(false) , do_replace(false) - , source_name(source_name) - , new_name(new_name) + , source_name(std::move(source_name)) + , new_name(std::move(new_name)) { } @@ -179,7 +179,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con // Create controls StyleName = new wxTextCtrl(this, -1, to_wx(style->name)); - FontName = new wxComboBox(this, -1, to_wx(style->font), wxDefaultPosition, wxSize(150, -1), 0, 0, wxCB_DROPDOWN); + FontName = new wxComboBox(this, -1, to_wx(style->font), wxDefaultPosition, wxSize(150, -1), 0, nullptr, wxCB_DROPDOWN); FontSize = num_text_ctrl(this, &work->fontsize, false, wxSize(50, -1)); BoxBold = new wxCheckBox(this, -1, _("&Bold")); BoxItalic = new wxCheckBox(this, -1, _("&Italic")); @@ -379,8 +379,8 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&DialogStyleEditor::Apply, this, false, true), wxID_CANCEL); Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, "Style Editor"), wxID_HELP); - for (int i = 0; i < 4; ++i) - colorButton[i]->Bind(EVT_COLOR, &DialogStyleEditor::OnSetColor, this); + for (auto const& elem : colorButton) + elem->Bind(EVT_COLOR, &DialogStyleEditor::OnSetColor, this); } DialogStyleEditor::~DialogStyleEditor() { diff --git a/aegisub/src/dialog_styling_assistant.cpp b/aegisub/src/dialog_styling_assistant.cpp index df001e371..9e6a1da34 100644 --- a/aegisub/src/dialog_styling_assistant.cpp +++ b/aegisub/src/dialog_styling_assistant.cpp @@ -56,7 +56,7 @@ DialogStyling::DialogStyling(agi::Context *context) : wxDialog(context->parent, -1, _("Styling Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX) , c(context) , active_line_connection(context->selectionController->AddActiveLineListener(&DialogStyling::OnActiveLineChanged, this)) -, active_line(0) +, active_line(nullptr) { SetIcon(GETICON(styling_toolbutton_16)); @@ -127,7 +127,7 @@ DialogStyling::DialogStyling(agi::Context *context) main_sizer->Add(bottom_sizer, 1, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5); { - wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer; + auto button_sizer = new wxStdDialogButtonSizer; button_sizer->AddButton(new wxButton(this, wxID_CANCEL)); button_sizer->AddButton(new HelpButton(this, "Styling Assistant")); button_sizer->Realize(); diff --git a/aegisub/src/dialog_timing_processor.cpp b/aegisub/src/dialog_timing_processor.cpp index a0cfd099c..37cbb537e 100644 --- a/aegisub/src/dialog_timing_processor.cpp +++ b/aegisub/src/dialog_timing_processor.cpp @@ -390,9 +390,7 @@ void DialogTimingProcessor::Process() { if (c->videoController->IsLoaded()) kf.push_back(c->videoController->GetLength() - 1); - for (size_t i = 0; i < sorted.size(); ++i) { - AssDialogue *cur = sorted[i]; - + for (AssDialogue *cur : sorted) { // Get start/end frames int startF = c->videoController->FrameAtTime(cur->Start, agi::vfr::START); int endF = c->videoController->FrameAtTime(cur->End, agi::vfr::END); diff --git a/aegisub/src/dialog_translation.cpp b/aegisub/src/dialog_translation.cpp index 7ccf8b757..993a4461a 100644 --- a/aegisub/src/dialog_translation.cpp +++ b/aegisub/src/dialog_translation.cpp @@ -93,7 +93,7 @@ DialogTranslation::DialogTranslation(agi::Context *c) } { - translated_text = new SubsTextEditCtrl(this, wxSize(320, 80), 0, 0); + translated_text = new SubsTextEditCtrl(this, wxSize(320, 80), 0, nullptr); translated_text->SetWrapMode(wxSTC_WRAP_WORD); translated_text->SetMarginWidth(1, 0); translated_text->SetFocus(); @@ -145,7 +145,7 @@ DialogTranslation::DialogTranslation(agi::Context *c) main_sizer->Add(right_box, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5); { - wxStdDialogButtonSizer *standard_buttons = new wxStdDialogButtonSizer(); + auto standard_buttons = new wxStdDialogButtonSizer(); standard_buttons->AddButton(new wxButton(this, wxID_CANCEL)); standard_buttons->AddButton(new HelpButton(this, "Translation Assistant")); standard_buttons->Realize(); diff --git a/aegisub/src/dialog_version_check.cpp b/aegisub/src/dialog_version_check.cpp index 1437190c7..9eaf1c15e 100644 --- a/aegisub/src/dialog_version_check.cpp +++ b/aegisub/src/dialog_version_check.cpp @@ -89,8 +89,8 @@ struct AegisubUpdateDescription { std::string friendly_name; std::string description; - AegisubUpdateDescription(std::string const& url, std::string const& friendly_name, std::string const& description) - : url(url), friendly_name(friendly_name), description(description) { } + AegisubUpdateDescription(std::string url, std::string friendly_name, std::string description) + : url(std::move(url)), friendly_name(std::move(friendly_name)), description(std::move(description)) { } }; class VersionCheckerResultDialog : public wxDialog { @@ -103,11 +103,11 @@ class VersionCheckerResultDialog : public wxDialog { public: VersionCheckerResultDialog(wxString const& main_text, const std::vector &updates); - bool ShouldPreventAppExit() const { return false; } + bool ShouldPreventAppExit() const override { return false; } }; VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text, const std::vector &updates) -: wxDialog(0, -1, _("Version Checker")) +: wxDialog(nullptr, -1, _("Version Checker")) { const int controls_width = 500; @@ -135,7 +135,7 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text automatic_check_checkbox = new wxCheckBox(this, -1, _("&Auto Check for Updates")); automatic_check_checkbox->SetValue(OPT_GET("App/Auto/Check For Updates")->GetBool()); - wxButton *remind_later_button = 0; + wxButton *remind_later_button = nullptr; if (updates.size() > 0) remind_later_button = new wxButton(this, wxID_NO, _("Remind me again in a &week")); @@ -147,7 +147,7 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6); main_sizer->Add(automatic_check_checkbox, 0, wxEXPAND|wxBOTTOM, 6); - wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer(); + auto button_sizer = new wxStdDialogButtonSizer(); button_sizer->AddButton(close_button); if (remind_later_button) button_sizer->AddButton(remind_later_button); diff --git a/aegisub/src/dialog_video_details.cpp b/aegisub/src/dialog_video_details.cpp index 7ee2411b2..66796c07b 100644 --- a/aegisub/src/dialog_video_details.cpp +++ b/aegisub/src/dialog_video_details.cpp @@ -57,7 +57,7 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c) auto fps = c->videoController->FPS(); boost::rational ar(width, height); - wxFlexGridSizer *fg = new wxFlexGridSizer(2, 5, 10); + auto fg = new wxFlexGridSizer(2, 5, 10); auto make_field = [&](wxString const& name, wxString const& value) { fg->Add(new wxStaticText(this, -1, name), 0, wxALIGN_CENTRE_VERTICAL); fg->Add(new wxTextCtrl(this, -1, value, wxDefaultPosition, wxSize(300,-1), wxTE_READONLY), 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND); @@ -71,7 +71,7 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c) wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Video")); video_sizer->Add(fg); - wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); + auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5); main_sizer->Add(CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5); SetSizerAndFit(main_sizer); diff --git a/aegisub/src/export_fixstyle.h b/aegisub/src/export_fixstyle.h index f31e60080..6de4d5a88 100644 --- a/aegisub/src/export_fixstyle.h +++ b/aegisub/src/export_fixstyle.h @@ -38,6 +38,6 @@ /// @brief Fixes styles by replacing any style that isn't available on file with Default class AssFixStylesFilter : public AssExportFilter { public: - void ProcessSubs(AssFile *subs, wxWindow *); + void ProcessSubs(AssFile *subs, wxWindow *) override; AssFixStylesFilter(); }; diff --git a/aegisub/src/export_framerate.cpp b/aegisub/src/export_framerate.cpp index ccd318b46..2ad31d137 100644 --- a/aegisub/src/export_framerate.cpp +++ b/aegisub/src/export_framerate.cpp @@ -59,14 +59,14 @@ AssTransformFramerateFilter::AssTransformFramerateFilter() : AssExportFilter(from_wx(_("Transform Framerate")), from_wx(_("Transform subtitle times, including those in override tags, from an input framerate to an output framerate.\n\nThis is useful for converting regular time subtitles to VFRaC time subtitles for hardsubbing.\nIt can also be used to convert subtitles to a different speed video, such as NTSC to PAL speedup.")), 1000) -, c(0) -, line(0) +, c(nullptr) +, line(nullptr) , newStart(0) , newEnd(0) , newK(0) , oldK(0) -, Input(0) -, Output(0) +, Input(nullptr) +, Output(nullptr) { } diff --git a/aegisub/src/export_framerate.h b/aegisub/src/export_framerate.h index c5717c7fc..71f46c6cc 100644 --- a/aegisub/src/export_framerate.h +++ b/aegisub/src/export_framerate.h @@ -87,7 +87,7 @@ class AssTransformFramerateFilter : public AssExportFilter { public: /// Constructor AssTransformFramerateFilter(); - void ProcessSubs(AssFile *subs, wxWindow *); - wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c); - void LoadSettings(bool is_default, agi::Context *c); + void ProcessSubs(AssFile *subs, wxWindow *) override; + wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c) override; + void LoadSettings(bool is_default, agi::Context *c) override; }; diff --git a/aegisub/src/font_file_lister.cpp b/aegisub/src/font_file_lister.cpp index 4aa9110e6..b7f6920ae 100644 --- a/aegisub/src/font_file_lister.cpp +++ b/aegisub/src/font_file_lister.cpp @@ -62,7 +62,7 @@ namespace { } FontCollector::FontCollector(FontCollectorStatusCallback status_callback, FontFileLister &lister) -: status_callback(status_callback) +: status_callback(std::move(status_callback)) , lister(lister) , missing(0) , missing_glyphs(0) @@ -146,9 +146,9 @@ void FontCollector::ProcessChunk(std::pair const& style) { ++missing; } else { - for (size_t i = 0; i < res.paths.size(); ++i) { - if (results.insert(res.paths[i]).second) - status_callback(wxString::Format(_("Found '%s' at '%s'\n"), to_wx(style.first.facename), res.paths[i].make_preferred().wstring()), 0); + for (auto& elem : res.paths) { + if (results.insert(elem).second) + status_callback(wxString::Format(_("Found '%s' at '%s'\n"), to_wx(style.first.facename), elem.make_preferred().wstring()), 0); } if (res.missing.size()) { diff --git a/aegisub/src/font_file_lister_fontconfig.h b/aegisub/src/font_file_lister_fontconfig.h index 5d8075d94..a9d3542b0 100644 --- a/aegisub/src/font_file_lister_fontconfig.h +++ b/aegisub/src/font_file_lister_fontconfig.h @@ -42,5 +42,5 @@ public: /// @param cb Callback for status logging FontConfigFontFileLister(FontCollectorStatusCallback cb); - CollectionResult GetFontPaths(std::string const& facename, int bold, bool italic, std::set const& characters); + CollectionResult GetFontPaths(std::string const& facename, int bold, bool italic, std::set const& characters) override; }; diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index b5505a347..b3ae45cc0 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -166,14 +166,14 @@ class AegisubFileDropTarget : public wxFileDropTarget { FrameMain *parent; public: AegisubFileDropTarget(FrameMain *parent) : parent(parent) { } - bool OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) { + bool OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) override { std::string subs, audio, video; get_files_to_load(filenames, subs, audio, video); if (subs.empty() && audio.empty() && video.empty()) return false; - wxThreadEvent *evt = new wxThreadEvent(FILE_LIST_DROPPED); + auto evt = new wxThreadEvent(FILE_LIST_DROPPED); evt->SetPayload(filenames); parent->QueueEvent(evt); return true; @@ -203,9 +203,9 @@ FrameMain::FrameMain() // anything involving unicode and in some cases number formatting. // The right thing to do here would be to query CoreFoundation for the user's // locale and add .UTF-8 to that, but :effort: - LOG_D("locale") << setlocale(LC_ALL, 0); + LOG_D("locale") << setlocale(LC_ALL, nullptr); setlocale(LC_CTYPE, "en_US.UTF-8"); - LOG_D("locale") << setlocale(LC_ALL, 0); + LOG_D("locale") << setlocale(LC_ALL, nullptr); #endif StartupLog("Initializing context models"); @@ -225,14 +225,14 @@ FrameMain::FrameMain() context->local_scripts = new Automation4::LocalScriptManager(context.get()); // Initialized later due to that the selection controller is currently the subtitles grid - context->selectionController = 0; + context->selectionController = nullptr; context->videoController = VideoContext::Get(); // derp context->videoController->AddVideoOpenListener(&FrameMain::OnVideoOpen, this); StartupLog("Initializing context frames"); context->parent = this; - context->previousFocus = 0; + context->previousFocus = nullptr; StartupLog("Install PNG handler"); wxImage::AddHandler(new wxPNGHandler); @@ -325,7 +325,7 @@ static bool delete_children(wxWindow *window, wxWindow *keep) { } FrameMain::~FrameMain () { - wxGetApp().frame = 0; + wxGetApp().frame = nullptr; context->videoController->SetVideo(""); context->audioController->CloseAudio(); @@ -355,7 +355,7 @@ void FrameMain::EnableToolBar(agi::OptionValue const& opt) { } } else if (wxToolBar *old_tb = GetToolBar()) { - SetToolBar(0); + SetToolBar(nullptr); delete old_tb; Layout(); } @@ -378,7 +378,7 @@ void FrameMain::InitContents() { context->audioBox = audioBox = new AudioBox(Panel, context.get()); StartupLog("Create subtitle editing box"); - SubsEditBox *EditBox = new SubsEditBox(Panel, context.get()); + auto EditBox = new SubsEditBox(Panel, context.get()); StartupLog("Arrange main sizers"); ToolsSizer = new wxBoxSizer(wxVERTICAL); diff --git a/aegisub/src/help_button.cpp b/aegisub/src/help_button.cpp index 8463e3522..4ef30f169 100644 --- a/aegisub/src/help_button.cpp +++ b/aegisub/src/help_button.cpp @@ -47,7 +47,7 @@ #include -static std::map *pages = 0; +static std::map *pages = nullptr; static void init_static() { if (!pages) { @@ -83,7 +83,7 @@ HelpButton::HelpButton(wxWindow *parent, wxString const& page, wxPoint position, Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, page)); init_static(); if (pages->find(page) == pages->end()) - throw agi::InternalError("Invalid help page", 0); + throw agi::InternalError("Invalid help page", nullptr); } void HelpButton::OpenPage(wxString const& pageID) { diff --git a/aegisub/src/hotkey.cpp b/aegisub/src/hotkey.cpp index 4f0c068d5..8eb36310b 100644 --- a/aegisub/src/hotkey.cpp +++ b/aegisub/src/hotkey.cpp @@ -33,21 +33,21 @@ namespace { const char *added_hotkeys_7035[][5] = { - { "audio/play/line", "Audio", "R", 0, 0 }, - { 0 } + { "audio/play/line", "Audio", "R", nullptr, nullptr }, + { nullptr } }; const char *added_hotkeys_7070[][5] = { - { "edit/color/primary", "Subtitle Edit Box", "Alt", "1", 0 }, - { "edit/color/secondary", "Subtitle Edit Box", "Alt", "2", 0 }, - { "edit/color/outline", "Subtitle Edit Box", "Alt", "3", 0 }, - { "edit/color/shadow", "Subtitle Edit Box", "Alt", "4", 0 }, - { 0 } + { "edit/color/primary", "Subtitle Edit Box", "Alt", "1", nullptr }, + { "edit/color/secondary", "Subtitle Edit Box", "Alt", "2", nullptr }, + { "edit/color/outline", "Subtitle Edit Box", "Alt", "3", nullptr }, + { "edit/color/shadow", "Subtitle Edit Box", "Alt", "4", nullptr }, + { nullptr } }; const char *added_hotkeys_shift_back[][5] = { { "edit/line/duplicate/shift_back", "Default", "Ctrl", "Shift", "D" }, - { 0 } + { nullptr } }; void migrate_hotkeys(const char *added[][5]) { @@ -73,7 +73,7 @@ namespace { namespace hotkey { -agi::hotkey::Hotkey *inst = 0; +agi::hotkey::Hotkey *inst = nullptr; void init() { inst = new agi::hotkey::Hotkey( config::path->Decode("?user/hotkey.json"), diff --git a/aegisub/src/hotkey_data_view_model.cpp b/aegisub/src/hotkey_data_view_model.cpp index 4d66c2dd8..7c338efc3 100644 --- a/aegisub/src/hotkey_data_view_model.cpp +++ b/aegisub/src/hotkey_data_view_model.cpp @@ -84,11 +84,11 @@ public: hk_map->insert(make_pair(combo.CmdName(), combo)); } - unsigned int GetChildren(wxDataViewItemArray &) const { return 0; } - wxDataViewItem GetParent() const { return wxDataViewItem(parent); } - bool IsContainer() const { return false; } + unsigned int GetChildren(wxDataViewItemArray &) const override { return 0; } + wxDataViewItem GetParent() const override { return wxDataViewItem(parent); } + bool IsContainer() const override { return false; } - void GetValue(wxVariant &variant, unsigned int col) const { + void GetValue(wxVariant &variant, unsigned int col) const override { if (col == 0) variant = to_wx(combo.Str()); else if (col == 1) { @@ -107,10 +107,10 @@ public: } } else - throw agi::InternalError("HotkeyDataViewModel asked for an invalid column number", 0); + throw agi::InternalError("HotkeyDataViewModel asked for an invalid column number", nullptr); } - bool SetValue(wxVariant const& variant, unsigned int col) { + bool SetValue(wxVariant const& variant, unsigned int col) override { if (col == 0) { wxArrayString toks = wxSplit(variant.GetString(), '-'); std::vector keys; @@ -195,17 +195,17 @@ public: } - wxDataViewItem GetParent() const { return wxDataViewItem(0); } - bool IsContainer() const { return true; } - bool SetValue(wxVariant const&, unsigned int) { return false; } - void GetValue(wxVariant &variant, unsigned int col) const { + wxDataViewItem GetParent() const override { return wxDataViewItem(nullptr); } + bool IsContainer() const override { return true; } + bool SetValue(wxVariant const&, unsigned int) override { return false; } + void GetValue(wxVariant &variant, unsigned int col) const override { if (col == 1) variant << wxDataViewIconText(name); else variant = name; } - unsigned int GetChildren(wxDataViewItemArray &out) const { + unsigned int GetChildren(wxDataViewItemArray &out) const override { out = visible_items; return out.size(); } @@ -244,12 +244,12 @@ public: category.SetFilter(filter); } - wxDataViewItem GetParent() const { return wxDataViewItem(0); } - bool IsContainer() const { return true; } - bool SetValue(wxVariant const&, unsigned int) { return false; } - void GetValue(wxVariant &, unsigned int) const { } + wxDataViewItem GetParent() const override { return wxDataViewItem(nullptr); } + bool IsContainer() const override { return true; } + bool SetValue(wxVariant const&, unsigned int) override { return false; } + void GetValue(wxVariant &, unsigned int) const override { } - unsigned int GetChildren(wxDataViewItemArray &out) const { + unsigned int GetChildren(wxDataViewItemArray &out) const override { out.reserve(categories.size()); for (auto const& category : categories) out.push_back(wxDataViewItem((void*)&category)); diff --git a/aegisub/src/hotkey_data_view_model.h b/aegisub/src/hotkey_data_view_model.h index 2a712450e..8937edaad 100644 --- a/aegisub/src/hotkey_data_view_model.h +++ b/aegisub/src/hotkey_data_view_model.h @@ -52,12 +52,12 @@ public: /// Only display hotkeys containing filter, or all if filter is empty void SetFilter(wxString const& filter); - unsigned int GetColumnCount() const { return 3; } - wxString GetColumnType(unsigned int) const { return "string"; } + unsigned int GetColumnCount() const override { return 3; } + wxString GetColumnType(unsigned int) const override { return "string"; } - unsigned int GetChildren(wxDataViewItem const& item, wxDataViewItemArray &children) const; - wxDataViewItem GetParent(wxDataViewItem const& item) const; - void GetValue(wxVariant &variant, wxDataViewItem const& item, unsigned int col) const; - bool IsContainer(wxDataViewItem const& item) const; - bool SetValue(wxVariant const& variant, wxDataViewItem const& item, unsigned int col); + unsigned int GetChildren(wxDataViewItem const& item, wxDataViewItemArray &children) const override; + wxDataViewItem GetParent(wxDataViewItem const& item) const override; + void GetValue(wxVariant &variant, wxDataViewItem const& item, unsigned int col) const override; + bool IsContainer(wxDataViewItem const& item) const override; + bool SetValue(wxVariant const& variant, wxDataViewItem const& item, unsigned int col) override; }; diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index dc1d64524..d2278b831 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -122,7 +122,7 @@ bool AegisubApp::OnInit() { // Pointless `this` capture required due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494 agi::dispatch::Init([this](agi::dispatch::Thunk f) { - wxThreadEvent *evt = new wxThreadEvent(EVT_CALL_THUNK); + auto evt = new wxThreadEvent(EVT_CALL_THUNK); evt->SetPayload(f); wxTheApp->QueueEvent(evt); }); @@ -304,7 +304,7 @@ class StackWalker: public wxStackWalker { public: StackWalker(std::string const& cause); ~StackWalker(); - void OnStackFrame(wxStackFrame const& frame); + void OnStackFrame(wxStackFrame const& frame) override; }; /// @brief Called at the start of walking the stack. diff --git a/aegisub/src/main.h b/aegisub/src/main.h index 9e6eb8ba2..aafda6e2f 100644 --- a/aegisub/src/main.h +++ b/aegisub/src/main.h @@ -45,12 +45,12 @@ class FrameMain; namespace Automation4 { class AutoloadScriptManager; } class AegisubApp: public wxApp { - bool OnInit(); - int OnExit(); - int OnRun(); + bool OnInit() override; + int OnExit() override; + int OnRun() override; - void OnUnhandledException(); - void OnFatalException(); + void OnUnhandledException() override; + void OnFatalException() override; /// @brief Handle wx assertions and redirect to the logging system. /// @param file File name @@ -58,11 +58,11 @@ class AegisubApp: public wxApp { /// @param func Function name /// @param cond Condition /// @param msg Message - void OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg); + void OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg) override; // This function wraps all event handler calls anywhere in the application and is // our ticket to catch exceptions happening in event handlers. - void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const; + void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const override; public: AegisubApp(); diff --git a/aegisub/src/menu.cpp b/aegisub/src/menu.cpp index 1d941648e..3d26741ea 100644 --- a/aegisub/src/menu.cpp +++ b/aegisub/src/menu.cpp @@ -72,8 +72,8 @@ class MruMenu : public wxMenu { } public: - MruMenu(std::string const& type, std::vector *cmds) - : type(type) + MruMenu(std::string type, std::vector *cmds) + : type(std::move(type)) , cmds(cmds) { } @@ -318,7 +318,7 @@ menu_items const& get_menu(std::string const& name) { return it->second; } -wxMenu *build_menu(std::string const& name, agi::Context *c, CommandManager *cm, wxMenu *menu = 0); +wxMenu *build_menu(std::string const& name, agi::Context *c, CommandManager *cm, wxMenu *menu = nullptr); /// Recursively process a single entry in the menu json /// @param parent Menu to add the item(s) from this entry to @@ -416,8 +416,8 @@ class AutomationMenu : public wxMenu { if (macros.empty()) Append(-1, _("No Automation macros loaded"))->Enable(false); else { - for (size_t i = 0; i < macros.size(); ++i) - cm->AddCommand(macros[i], this, ""); + for (auto const& macro : macros) + cm->AddCommand(macro, this, ""); } } public: @@ -477,7 +477,7 @@ namespace menu { } std::unique_ptr GetMenu(std::string const& name, agi::Context *c) { - CommandMenu *menu = new CommandMenu(c); + auto menu = new CommandMenu(c); build_menu(name, c, &menu->cm, menu); menu->Bind(wxEVT_MENU_OPEN, &CommandManager::OnMenuOpen, &menu->cm); menu->Bind(wxEVT_COMMAND_MENU_SELECTED, &CommandManager::OnMenuClick, &menu->cm); diff --git a/aegisub/src/persist_location.cpp b/aegisub/src/persist_location.cpp index 4db24aac8..a04475807 100644 --- a/aegisub/src/persist_location.cpp +++ b/aegisub/src/persist_location.cpp @@ -30,8 +30,8 @@ PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix, bool size_too) : x_opt(OPT_SET(options_prefix + "/Last/X")) , y_opt(OPT_SET(options_prefix + "/Last/Y")) -, w_opt(size_too ? OPT_SET(options_prefix + "/Last/Width") : 0) -, h_opt(size_too ? OPT_SET(options_prefix + "/Last/Height") : 0) +, w_opt(size_too ? OPT_SET(options_prefix + "/Last/Width") : nullptr) +, h_opt(size_too ? OPT_SET(options_prefix + "/Last/Height") : nullptr) , maximize_opt(OPT_SET(options_prefix + "/Maximized")) , dialog(dialog) { diff --git a/aegisub/src/placeholder_ctrl.h b/aegisub/src/placeholder_ctrl.h index 1ca3ff62f..122d78aec 100644 --- a/aegisub/src/placeholder_ctrl.h +++ b/aegisub/src/placeholder_ctrl.h @@ -114,5 +114,5 @@ public: }; template<> inline void Placeholder::Create(wxWindow *parent, wxSize const& size, long style) { - wxComboBox::Create(parent, -1, "", wxDefaultPosition, size, 0, 0, style); + wxComboBox::Create(parent, -1, "", wxDefaultPosition, size, 0, nullptr, style); } diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index 5b76c45de..b044c8422 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -275,7 +275,7 @@ public: { } - wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& value) { + wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& value) override { wxDataViewIconText iconText; iconText << value; @@ -292,12 +292,12 @@ public: return ctrl; } - bool SetValue(wxVariant const& var) { + bool SetValue(wxVariant const& var) override { value << var; return true; } - bool Render(wxRect rect, wxDC *dc, int state) { + bool Render(wxRect rect, wxDC *dc, int state) override { wxIcon const& icon = value.GetIcon(); if (icon.IsOk()) dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); @@ -307,7 +307,7 @@ public: return true; } - wxSize GetSize() const { + wxSize GetSize() const override { if (!value.GetText().empty()) { wxSize size = GetTextExtent(value.GetText()); size.x += icon_width; @@ -316,15 +316,15 @@ public: return wxSize(80,20); } - bool GetValueFromEditorCtrl(wxWindow* editor, wxVariant &var) { + bool GetValueFromEditorCtrl(wxWindow* editor, wxVariant &var) override { wxTextCtrl *text = static_cast(editor); wxDataViewIconText iconText(text->GetValue(), value.GetIcon()); var << iconText; return true; } - bool GetValue(wxVariant &) const { return false; } - bool HasEditorCtrl() const { return true; } + bool GetValue(wxVariant &) const override { return false; } + bool HasEditorCtrl() const override { return true; } }; class HotkeyRenderer : public wxDataViewCustomRenderer { @@ -334,10 +334,10 @@ class HotkeyRenderer : public wxDataViewCustomRenderer { public: HotkeyRenderer() : wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_EDITABLE) - , ctrl(0) + , ctrl(nullptr) { } - wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& var) { + wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& var) override { ctrl = new wxTextCtrl(parent, -1, var.GetString(), label_rect.GetPosition(), label_rect.GetSize(), wxTE_PROCESS_ENTER); ctrl->SetInsertionPointEnd(); ctrl->SelectAll(); @@ -349,24 +349,24 @@ public: ctrl->ChangeValue(to_wx(hotkey::keypress_to_str(evt.GetKeyCode(), evt.GetModifiers()))); } - bool SetValue(wxVariant const& var) { + bool SetValue(wxVariant const& var) override { value = var.GetString(); return true; } - bool Render(wxRect rect, wxDC *dc, int state) { + bool Render(wxRect rect, wxDC *dc, int state) override { RenderText(value, 0, rect, dc, state); return true; } - bool GetValueFromEditorCtrl(wxWindow*, wxVariant &var) { + bool GetValueFromEditorCtrl(wxWindow*, wxVariant &var) override { var = ctrl->GetValue(); return true; } - bool GetValue(wxVariant &) const { return false; } - wxSize GetSize() const { return !value ? wxSize(80, 20) : GetTextExtent(value); } - bool HasEditorCtrl() const { return true; } + bool GetValue(wxVariant &) const override { return false; } + wxSize GetSize() const override { return !value ? wxSize(80, 20) : GetTextExtent(value); } + bool HasEditorCtrl() const override { return true; } }; static void edit_item(wxDataViewCtrl *dvc, wxDataViewItem item) { @@ -436,7 +436,7 @@ void Interface_Hotkeys::OnUpdateFilter(wxCommandEvent&) { if (!quick_search->GetValue().empty()) { wxDataViewItemArray contexts; - model->GetChildren(wxDataViewItem(0), contexts); + model->GetChildren(wxDataViewItem(nullptr), contexts); for (auto const& context : contexts) dvc->Expand(context); } diff --git a/aegisub/src/preferences_base.cpp b/aegisub/src/preferences_base.cpp index cae81045f..dcfc75a83 100644 --- a/aegisub/src/preferences_base.cpp +++ b/aegisub/src/preferences_base.cpp @@ -62,7 +62,7 @@ OPTION_UPDATER(BoolUpdater, wxCommandEvent, OptionValueBool, !!evt.GetInt()); OPTION_UPDATER(ColourUpdater, wxThreadEvent, OptionValueColor, evt.GetPayload()); static void browse_button(wxTextCtrl *ctrl) { - wxDirDialog dlg(0, _("Please choose the folder:"), config::path->Decode(from_wx(ctrl->GetValue())).wstring()); + wxDirDialog dlg(nullptr, _("Please choose the folder:"), config::path->Decode(from_wx(ctrl->GetValue())).wstring()); if (dlg.ShowModal() == wxID_OK) { wxString dir = dlg.GetPath(); if (!dir.empty()) @@ -147,7 +147,7 @@ wxControl *OptionPage::OptionAdd(wxFlexGridSizer *flex, const wxString &name, co } case agi::OptionValue::Type_Color: { - ColourButton *cb = new ColourButton(this, wxSize(40,10), false, opt->GetColor()); + auto cb = new ColourButton(this, wxSize(40,10), false, opt->GetColor()); cb->Bind(EVT_COLOR, ColourUpdater(opt_name, parent)); Add(flex, name, cb); return cb; @@ -190,7 +190,7 @@ void OptionPage::OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxFlexGridSizer* OptionPage::PageSizer(wxString name) { wxSizer *tmp_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, name); sizer->Add(tmp_sizer, 0,wxEXPAND, 5); - wxFlexGridSizer *flex = new wxFlexGridSizer(2,5,5); + auto flex = new wxFlexGridSizer(2,5,5); flex->AddGrowableCol(0,1); tmp_sizer->Add(flex, 1, wxEXPAND, 5); sizer->AddSpacer(8); diff --git a/aegisub/src/preferences_base.h b/aegisub/src/preferences_base.h index cda47beed..b38052a9c 100644 --- a/aegisub/src/preferences_base.h +++ b/aegisub/src/preferences_base.h @@ -45,7 +45,7 @@ protected: void CellSkip(wxFlexGridSizer *flex); wxControl *OptionAdd(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, double min=0, double max=INT_MAX, double inc=1); void OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxArrayString &choices, const char *opt_name); - void OptionBrowse(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, wxControl *enabler = 0, bool do_enable = false); + void OptionBrowse(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, wxControl *enabler = nullptr, bool do_enable = false); void OptionFont(wxSizer *sizer, std::string opt_prefix); public: diff --git a/aegisub/src/scintilla_text_selection_controller.h b/aegisub/src/scintilla_text_selection_controller.h index af08a0e46..e040e1f11 100644 --- a/aegisub/src/scintilla_text_selection_controller.h +++ b/aegisub/src/scintilla_text_selection_controller.h @@ -22,12 +22,12 @@ class ScintillaTextSelectionController : public TextSelectionController { ScintillaTextCtrl *ctrl; public: - void SetSelection(int start, int end); - void SetInsertionPoint(int point); + void SetSelection(int start, int end) override; + void SetInsertionPoint(int point) override; - int GetSelectionStart() const; - int GetSelectionEnd() const; - int GetInsertionPoint() const; + int GetSelectionStart() const override; + int GetSelectionEnd() const override; + int GetInsertionPoint() const override; ScintillaTextSelectionController(ScintillaTextCtrl *ctrl); }; diff --git a/aegisub/src/search_replace_engine.cpp b/aegisub/src/search_replace_engine.cpp index 0c7674fd6..33e2de1c7 100644 --- a/aegisub/src/search_replace_engine.cpp +++ b/aegisub/src/search_replace_engine.cpp @@ -41,7 +41,7 @@ auto get_dialogue_field(SearchReplaceSettings::Field field) -> decltype(&AssDial case SearchReplaceSettings::Field::ACTOR: return &AssDialogue::Actor; case SearchReplaceSettings::Field::EFFECT: return &AssDialogue::Effect; } - throw agi::InternalError("Bad field for search", 0); + throw agi::InternalError("Bad field for search", nullptr); } std::string const& get_normalized(const AssDialogue *diag, decltype(&AssDialogue::Text) field) { diff --git a/aegisub/src/spellchecker_hunspell.cpp b/aegisub/src/spellchecker_hunspell.cpp index 17d6cbc87..cd8a21cff 100644 --- a/aegisub/src/spellchecker_hunspell.cpp +++ b/aegisub/src/spellchecker_hunspell.cpp @@ -174,8 +174,8 @@ std::vector HunspellSpellChecker::GetLanguageList() { sort(begin(aff), end(aff)); // Drop extensions - for (size_t i = 0; i < dic.size(); ++i) dic[i].resize(dic[i].size() - 4); - for (size_t i = 0; i < aff.size(); ++i) aff[i].resize(aff[i].size() - 4); + for (auto& elem : dic) elem.resize(elem.size() - 4); + for (auto& elem : aff) elem.resize(elem.size() - 4); // Verify that each aff has a dic for (size_t i = 0, j = 0; i < dic.size() && j < aff.size(); ) { diff --git a/aegisub/src/spellchecker_hunspell.h b/aegisub/src/spellchecker_hunspell.h index 2f64e6fcd..4789cbc21 100644 --- a/aegisub/src/spellchecker_hunspell.h +++ b/aegisub/src/spellchecker_hunspell.h @@ -69,13 +69,13 @@ public: HunspellSpellChecker(); ~HunspellSpellChecker(); - void AddWord(std::string const& word); - void RemoveWord(std::string const& word); - bool CanAddWord(std::string const& word); - bool CanRemoveWord(std::string const& word); - bool CheckWord(std::string const& word); - std::vector GetSuggestions(std::string const& word); - std::vector GetLanguageList(); + void AddWord(std::string const& word) override; + void RemoveWord(std::string const& word) override; + bool CanAddWord(std::string const& word) override; + bool CanRemoveWord(std::string const& word) override; + bool CheckWord(std::string const& word) override; + std::vector GetSuggestions(std::string const& word) override; + std::vector GetLanguageList() override; }; #endif diff --git a/aegisub/src/spline.cpp b/aegisub/src/spline.cpp index 5494fb3f4..866c479b1 100644 --- a/aegisub/src/spline.cpp +++ b/aegisub/src/spline.cpp @@ -161,8 +161,8 @@ void Spline::DecodeFromAss(std::string const& str) { } void Spline::MovePoint(iterator curve,int point,Vector2D pos) { - iterator prev = std::prev(curve, curve != begin()); - iterator next = std::next(curve); + auto prev = std::prev(curve, curve != begin()); + auto next = std::next(curve); if (next != end() && next->type == SplineCurve::POINT) next = end(); @@ -198,8 +198,8 @@ void Spline::GetPointList(std::vector& points, std::vector& first, s int curCount = 0; // Generate points for each curve - for (iterator cur = begin(); cur != end(); ++cur) { - if (cur->type == SplineCurve::POINT) { + for (auto const& elem : *this) { + if (elem.type == SplineCurve::POINT) { if (curCount > 0) count.push_back(curCount); @@ -207,7 +207,7 @@ void Spline::GetPointList(std::vector& points, std::vector& first, s first.push_back(points.size() / 2); curCount = 0; } - curCount += cur->GetPoints(points); + curCount += elem.GetPoints(points); } count.push_back(curCount); @@ -241,7 +241,7 @@ void Spline::GetClosestParametricPoint(Vector2D reference,iterator &curve,float emplace_back(back().EndPoint(), front().p1); float closest = std::numeric_limits::infinity(); - for (iterator cur = begin(); cur != end(); ++cur) { + for (auto cur = begin(); cur != end(); ++cur) { float param = cur->GetClosestParam(reference); Vector2D p1 = cur->GetPoint(param); float dist = (p1-reference).SquareLen(); @@ -274,9 +274,9 @@ void Spline::Smooth(float smooth) { if (size() < 3) return; // Smooth curve - for (iterator cur = begin(); cur != end(); ++cur) { - iterator prev_curve = prev(cur != begin() ? cur : end()); - iterator next_curve = next(cur); + for (auto cur = begin(); cur != end(); ++cur) { + auto prev_curve = prev(cur != begin() ? cur : end()); + auto next_curve = next(cur); if (next_curve == end()) next_curve = begin(); diff --git a/aegisub/src/spline_curve.cpp b/aegisub/src/spline_curve.cpp index 4d0d5a30a..48df6409f 100644 --- a/aegisub/src/spline_curve.cpp +++ b/aegisub/src/spline_curve.cpp @@ -40,10 +40,10 @@ #include #include -SplineCurve::SplineCurve(Vector2D p1) : p1(p1), type(POINT) { } -SplineCurve::SplineCurve(Vector2D p1, Vector2D p2) : p1(p1), p2(p2), type(LINE) { } +SplineCurve::SplineCurve(Vector2D p1) : p1(std::move(p1)), type(POINT) { } +SplineCurve::SplineCurve(Vector2D p1, Vector2D p2) : p1(std::move(p1)), p2(std::move(p2)), type(LINE) { } SplineCurve::SplineCurve(Vector2D p1, Vector2D p2, Vector2D p3, Vector2D p4) -: p1(p1), p2(p2), p3(p3), p4(p4), type(BICUBIC) +: p1(std::move(p1)), p2(std::move(p2)), p3(std::move(p3)), p4(std::move(p4)), type(BICUBIC) { } diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index 29d5a81cc..61371c09c 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -424,7 +424,7 @@ void SubsEditBox::SetSelectedRows(setter set, wxString const& desc, int type, bo for_each(sel.begin(), sel.end(), set); file_changed_slot.Block(); - commit_id = c->ass->Commit(desc, type, (amend && desc == last_commit_type) ? commit_id : -1, sel.size() == 1 ? *sel.begin() : 0); + commit_id = c->ass->Commit(desc, type, (amend && desc == last_commit_type) ? commit_id : -1, sel.size() == 1 ? *sel.begin() : nullptr); file_changed_slot.Unblock(); last_commit_type = desc; last_time_commit_type = -1; @@ -487,7 +487,7 @@ void SubsEditBox::CommitTimes(TimeField field) { last_time_commit_type = field; file_changed_slot.Block(); - commit_id = c->ass->Commit(_("modify times"), AssFile::COMMIT_DIAG_TIME, commit_id, sel.size() == 1 ? *sel.begin() : 0); + commit_id = c->ass->Commit(_("modify times"), AssFile::COMMIT_DIAG_TIME, commit_id, sel.size() == 1 ? *sel.begin() : nullptr); file_changed_slot.Unblock(); } diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index 986534075..3a2e16d7a 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -230,7 +230,7 @@ void SubsTextEditCtrl::SetStyles() { } void SubsTextEditCtrl::UpdateStyle() { - AssDialogue *diag = context ? context->selectionController->GetActiveLine() : 0; + AssDialogue *diag = context ? context->selectionController->GetActiveLine() : nullptr; bool template_line = diag && diag->Comment && boost::istarts_with(diag->Effect.get(), "template"); tokenized_line = agi::ass::TokenizeDialogueBody(line_text, template_line); @@ -366,7 +366,7 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { if (sugs.empty()) menu.Append(EDIT_MENU_SUGGESTION,_("No spell checker suggestions"))->Enable(false); else { - wxMenu *subMenu = new wxMenu; + auto subMenu = new wxMenu; for (size_t i = 0; i < sugs.size(); ++i) subMenu->Append(EDIT_MENU_SUGGESTIONS+i, to_wx(sugs[i])); @@ -396,7 +396,7 @@ void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { thesSugs.clear(); if (results.size()) { - wxMenu *thesMenu = new wxMenu; + auto thesMenu = new wxMenu; int curThesEntry = 0; for (auto const& result : results) { @@ -408,7 +408,7 @@ void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { } // Multiple, create submenu else { - wxMenu *subMenu = new wxMenu; + auto subMenu = new wxMenu; for (auto const& sug : result.second) { subMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, to_wx(sug)); thesSugs.push_back(sug); @@ -433,7 +433,7 @@ void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { } wxMenu *SubsTextEditCtrl::GetLanguagesMenu(int base_id, wxString const& curLang, wxArrayString const& langs) { - wxMenu *languageMenu = new wxMenu; + auto languageMenu = new wxMenu; languageMenu->AppendRadioItem(base_id, _("Disable"))->Check(curLang.empty()); for (size_t i = 0; i < langs.size(); ++i) { diff --git a/aegisub/src/subs_edit_ctrl.h b/aegisub/src/subs_edit_ctrl.h index 67a15ed25..fd754c4bc 100644 --- a/aegisub/src/subs_edit_ctrl.h +++ b/aegisub/src/subs_edit_ctrl.h @@ -123,7 +123,7 @@ public: ~SubsTextEditCtrl(); void SetTextTo(wxString const& text); - void Paste(); + void Paste() override; std::pair GetBoundsOfWordAtPosition(int pos); diff --git a/aegisub/src/subs_preview.cpp b/aegisub/src/subs_preview.cpp index 9f9c7e8e0..ab1d1a87a 100644 --- a/aegisub/src/subs_preview.cpp +++ b/aegisub/src/subs_preview.cpp @@ -51,7 +51,7 @@ SubtitlesPreview::SubtitlesPreview(wxWindow *parent, wxSize size, int winStyle, agi::Color col) : wxWindow(parent, -1, wxDefaultPosition, size, winStyle) , style(new AssStyle) -, back_color(col) +, back_color(std::move(col)) , sub_file(agi::util::make_unique()) , line(new AssDialogue) { diff --git a/aegisub/src/subtitle_format.cpp b/aegisub/src/subtitle_format.cpp index 35be78db3..0c64b1670 100644 --- a/aegisub/src/subtitle_format.cpp +++ b/aegisub/src/subtitle_format.cpp @@ -66,8 +66,8 @@ using namespace std::placeholders; -SubtitleFormat::SubtitleFormat(std::string const& name) -: name(name) +SubtitleFormat::SubtitleFormat(std::string name) +: name(std::move(name)) { formats.push_back(this); } @@ -242,7 +242,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { //Is there an A part before the overlap? if (curdlg->Start > prevdlg->Start) { // Produce new entry with correct values - AssDialogue *newdlg = new AssDialogue(*prevdlg); + auto newdlg = new AssDialogue(*prevdlg); newdlg->Start = prevdlg->Start; newdlg->End = curdlg->Start; newdlg->Text = prevdlg->Text; @@ -252,7 +252,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { // Overlapping A+B part { - AssDialogue *newdlg = new AssDialogue(*prevdlg); + auto newdlg = new AssDialogue(*prevdlg); newdlg->Start = curdlg->Start; newdlg->End = (prevdlg->End < curdlg->End) ? prevdlg->End : curdlg->End; // Put an ASS format hard linewrap between lines @@ -264,7 +264,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { // Is there an A part after the overlap? if (prevdlg->End > curdlg->End) { // Produce new entry with correct values - AssDialogue *newdlg = new AssDialogue(*prevdlg); + auto newdlg = new AssDialogue(*prevdlg); newdlg->Start = curdlg->End; newdlg->End = prevdlg->End; newdlg->Text = prevdlg->Text; @@ -275,7 +275,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { // Is there a B part after the overlap? if (curdlg->End > prevdlg->End) { // Produce new entry with correct values - AssDialogue *newdlg = new AssDialogue(*prevdlg); + auto newdlg = new AssDialogue(*prevdlg); newdlg->Start = prevdlg->End; newdlg->End = curdlg->End; newdlg->Text = curdlg->Text; @@ -332,7 +332,7 @@ template SubtitleFormat *find_or_throw(Cont &container, Pred pred) { auto it = find_if(container.begin(), container.end(), pred); if (it == container.end()) - throw UnknownSubtitleFormatError("Subtitle format for extension not found", 0); + throw UnknownSubtitleFormatError("Subtitle format for extension not found", nullptr); return *it; } diff --git a/aegisub/src/subtitle_format.h b/aegisub/src/subtitle_format.h index 02ba14dae..70eb5974f 100644 --- a/aegisub/src/subtitle_format.h +++ b/aegisub/src/subtitle_format.h @@ -81,7 +81,7 @@ public: /// Constructor /// @param Subtitle format name /// @note Automatically registers the format - SubtitleFormat(std::string const& name); + SubtitleFormat(std::string name); /// Destructor /// @note Automatically unregisters the format virtual ~SubtitleFormat(); diff --git a/aegisub/src/subtitle_format_ass.cpp b/aegisub/src/subtitle_format_ass.cpp index 856d1cfa1..4c9201cc3 100644 --- a/aegisub/src/subtitle_format_ass.cpp +++ b/aegisub/src/subtitle_format_ass.cpp @@ -76,7 +76,7 @@ void AssSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, parser.AddLine(line); } catch (const char *err) { - throw AssParseError("Error processing line: " + line + ": " + err, 0); + throw AssParseError("Error processing line: " + line + ": " + err, nullptr); } } } diff --git a/aegisub/src/subtitle_format_ebu3264.cpp b/aegisub/src/subtitle_format_ebu3264.cpp index 5d821c7d7..30913febc 100644 --- a/aegisub/src/subtitle_format_ebu3264.cpp +++ b/aegisub/src/subtitle_format_ebu3264.cpp @@ -104,7 +104,7 @@ namespace bool underline; ///< Is this block underlined? bool italic; ///< Is this block italic? bool word_start; ///< Is it safe to line-wrap between this block and the previous one? - EbuFormattedText(std::string const& t, bool u = false, bool i = false, bool ws = true) : text(t), underline(u), italic(i), word_start(ws) { } + EbuFormattedText(std::string t, bool u = false, bool i = false, bool ws = true) : text(std::move(t)), underline(u), italic(i), word_start(ws) { } }; typedef std::vector EbuTextRow; @@ -407,7 +407,7 @@ namespace else if (!imline.CheckLineLengths(export_settings.max_line_length)) { if (export_settings.line_wrapping_mode == EbuExportSettings::AbortOverLength) - throw Ebu3264SubtitleFormat::ConversionFailed(from_wx(wxString::Format(_("Line over maximum length: %s"), line->Text.get())), 0); + throw Ebu3264SubtitleFormat::ConversionFailed(from_wx(wxString::Format(_("Line over maximum length: %s"), line->Text.get())), nullptr); else // skip over-long lines subs_list.pop_back(); } @@ -518,7 +518,7 @@ namespace } // produce blocks from string - static const size_t block_size = sizeof(((BlockTTI*)0)->tf); + static const size_t block_size = sizeof(((BlockTTI*)nullptr)->tf); uint8_t num_blocks = 0; for (size_t pos = 0; pos < fullstring.size(); pos += block_size) { @@ -640,7 +640,7 @@ std::vector Ebu3264SubtitleFormat::GetWriteWildcards() const void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const { // collect data from user - EbuExportSettings export_settings = get_export_config(0); + EbuExportSettings export_settings = get_export_config(nullptr); AssFile copy(*src); std::vector subs_list = convert_subtitles(copy, export_settings); diff --git a/aegisub/src/subtitle_format_microdvd.cpp b/aegisub/src/subtitle_format_microdvd.cpp index 588eb8e05..a5468fb67 100644 --- a/aegisub/src/subtitle_format_microdvd.cpp +++ b/aegisub/src/subtitle_format_microdvd.cpp @@ -116,7 +116,7 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file boost::replace_all(text, "|", "\\N"); - AssDialogue *diag = new AssDialogue; + auto diag = new AssDialogue; diag->Start = fps.TimeAtFrame(f1, agi::vfr::START); diag->End = fps.TimeAtFrame(f2, agi::vfr::END); diag->Text = text; diff --git a/aegisub/src/subtitle_format_srt.cpp b/aegisub/src/subtitle_format_srt.cpp index 4d20343b5..768903b22 100644 --- a/aegisub/src/subtitle_format_srt.cpp +++ b/aegisub/src/subtitle_format_srt.cpp @@ -367,7 +367,7 @@ void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, ParseState state = STATE_INITIAL; int line_num = 0; int linebreak_debt = 0; - AssDialogue *line = 0; + AssDialogue *line = nullptr; std::string text; while (file.HasMoreLines()) { std::string text_line = file.ReadLineFromFile(); @@ -387,11 +387,11 @@ void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, if (regex_search(text_line, timestamp_match, timestamp_regex)) goto found_timestamps; - throw SRTParseError(str(boost::format("Parsing SRT: Expected subtitle index at line %d") % line_num), 0); + throw SRTParseError(str(boost::format("Parsing SRT: Expected subtitle index at line %d") % line_num), nullptr); case STATE_TIMESTAMP: if (!regex_search(text_line, timestamp_match, timestamp_regex)) - throw SRTParseError(str(boost::format("Parsing SRT: Expected timestamp pair at line %d") % line_num), 0); + throw SRTParseError(str(boost::format("Parsing SRT: Expected timestamp pair at line %d") % line_num), nullptr); found_timestamps: if (line) { // finalize active line @@ -457,7 +457,7 @@ found_timestamps: } if (state == 1 || state == 2) - throw SRTParseError("Parsing SRT: Incomplete file", 0); + throw SRTParseError("Parsing SRT: Incomplete file", nullptr); if (line) // an unfinalized line line->Text = tag_parser.ToAss(text); diff --git a/aegisub/src/subtitle_format_transtation.cpp b/aegisub/src/subtitle_format_transtation.cpp index 061c7560f..eee8c1937 100644 --- a/aegisub/src/subtitle_format_transtation.cpp +++ b/aegisub/src/subtitle_format_transtation.cpp @@ -76,7 +76,7 @@ void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path cons SmpteFormatter ft(fps); TextFileWriter file(filename, encoding); - AssDialogue *prev = 0; + AssDialogue *prev = nullptr; for (auto cur : copy.Line | agi::of_type()) { if (prev) { file.WriteLineToFile(ConvertLine(©, prev, fps, ft, cur->Start)); diff --git a/aegisub/src/subtitle_format_ttxt.cpp b/aegisub/src/subtitle_format_ttxt.cpp index da2365c0e..96c7b23d8 100644 --- a/aegisub/src/subtitle_format_ttxt.cpp +++ b/aegisub/src/subtitle_format_ttxt.cpp @@ -69,10 +69,10 @@ void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename // Load XML document wxXmlDocument doc; - if (!doc.Load(filename.wstring())) throw TTXTParseError("Failed loading TTXT XML file.", 0); + if (!doc.Load(filename.wstring())) throw TTXTParseError("Failed loading TTXT XML file.", nullptr); // Check root node name - if (doc.GetRoot()->GetName() != "TextStream") throw TTXTParseError("Invalid TTXT file.", 0); + if (doc.GetRoot()->GetName() != "TextStream") throw TTXTParseError("Invalid TTXT file.", nullptr); // Check version wxString verStr = doc.GetRoot()->GetAttribute("version", ""); @@ -82,10 +82,10 @@ void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename else if (verStr == "1.1") version = 1; else - throw TTXTParseError("Unknown TTXT version: " + from_wx(verStr), 0); + throw TTXTParseError("Unknown TTXT version: " + from_wx(verStr), nullptr); // Get children - AssDialogue *diag = 0; + AssDialogue *diag = nullptr; int lines = 0; for (wxXmlNode *child = doc.GetRoot()->GetChildren(); child; child = child->GetNext()) { // Line @@ -123,10 +123,10 @@ AssDialogue *TTXTSubtitleFormat::ProcessLine(wxXmlNode *node, AssDialogue *prev, text = node->GetNodeContent(); // Create line - if (text.empty()) return 0; + if (text.empty()) return nullptr; // Create dialogue - AssDialogue *diag = new AssDialogue; + auto diag = new AssDialogue; diag->Start = time; diag->End = 36000000-10; @@ -176,7 +176,7 @@ void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& file WriteHeader(root); // Create lines - const AssDialogue *prev = 0; + const AssDialogue *prev = nullptr; for (auto current : copy.Line | agi::of_type()) { WriteLine(root, prev, current); prev = current; @@ -270,7 +270,7 @@ void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { } // Insert blank line at the end - AssDialogue *diag = new AssDialogue; + auto diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Line.push_back(*diag); diff --git a/aegisub/src/subtitle_format_txt.cpp b/aegisub/src/subtitle_format_txt.cpp index 81a96e173..2b4985672 100644 --- a/aegisub/src/subtitle_format_txt.cpp +++ b/aegisub/src/subtitle_format_txt.cpp @@ -89,7 +89,7 @@ void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, // Check if this isn't a timecodes file if (boost::starts_with(value, "# timecode")) - throw SubtitleFormatParseError("File is a timecode file, cannot load as subtitles.", 0); + throw SubtitleFormatParseError("File is a timecode file, cannot load as subtitles.", nullptr); // Read comment data bool isComment = false; @@ -117,7 +117,7 @@ void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, isComment = true; // Sets line up - AssDialogue *line = new AssDialogue; + auto line = new AssDialogue; line->Actor = isComment ? std::string() : actor; line->Comment = isComment; line->Text = value; diff --git a/aegisub/src/subtitles_provider_libass.h b/aegisub/src/subtitles_provider_libass.h index 9dd88f090..2a818c3cd 100644 --- a/aegisub/src/subtitles_provider_libass.h +++ b/aegisub/src/subtitles_provider_libass.h @@ -46,8 +46,8 @@ public: LibassSubtitlesProvider(std::string); ~LibassSubtitlesProvider(); - void LoadSubtitles(AssFile *subs); - void DrawSubtitles(VideoFrame &dst, double time); + void LoadSubtitles(AssFile *subs) override; + void DrawSubtitles(VideoFrame &dst, double time) override; static void CacheFonts(); }; diff --git a/aegisub/src/threaded_frame_source.cpp b/aegisub/src/threaded_frame_source.cpp index aaa888159..955ddb8ed 100644 --- a/aegisub/src/threaded_frame_source.cpp +++ b/aegisub/src/threaded_frame_source.cpp @@ -105,7 +105,7 @@ static std::unique_ptr get_subs_provider(wxEvtHandler *parent } catch (std::string const& err) { parent->AddPendingEvent(SubtitlesProviderErrorEvent(err)); - return 0; + return nullptr; } } @@ -129,7 +129,7 @@ ThreadedFrameSource::~ThreadedFrameSource() { void ThreadedFrameSource::LoadSubtitles(const AssFile *new_subs) throw() { uint_fast32_t req_version = ++version; - AssFile *copy = new AssFile(*new_subs); + auto copy = new AssFile(*new_subs); worker->Async([=]{ subs.reset(copy); single_frame = NEW_SUBS_FILE; diff --git a/aegisub/src/threaded_frame_source.h b/aegisub/src/threaded_frame_source.h index 9f3688582..1bcb7156a 100644 --- a/aegisub/src/threaded_frame_source.h +++ b/aegisub/src/threaded_frame_source.h @@ -116,24 +116,24 @@ struct FrameReadyEvent : public wxEvent { std::shared_ptr frame; /// Time which was used for subtitle rendering double time; - wxEvent *Clone() const { return new FrameReadyEvent(*this); }; + wxEvent *Clone() const override { return new FrameReadyEvent(*this); }; FrameReadyEvent(std::shared_ptr frame, double time) - : frame(frame), time(time) { } + : frame(std::move(frame)), time(time) { } }; // These exceptions are wxEvents so that they can be passed directly back to // the parent thread as events struct VideoProviderErrorEvent : public wxEvent, public agi::Exception { - const char * GetName() const { return "video/error"; } - wxEvent *Clone() const { return new VideoProviderErrorEvent(*this); }; - agi::Exception *Copy() const { return new VideoProviderErrorEvent(*this); }; + const char * GetName() const override { return "video/error"; } + wxEvent *Clone() const override { return new VideoProviderErrorEvent(*this); }; + agi::Exception *Copy() const override { return new VideoProviderErrorEvent(*this); }; VideoProviderErrorEvent(VideoProviderError const& err); }; struct SubtitlesProviderErrorEvent : public wxEvent, public agi::Exception { - const char * GetName() const { return "subtitles/error"; } - wxEvent *Clone() const { return new SubtitlesProviderErrorEvent(*this); }; - agi::Exception *Copy() const { return new SubtitlesProviderErrorEvent(*this); }; + const char * GetName() const override { return "subtitles/error"; } + wxEvent *Clone() const override { return new SubtitlesProviderErrorEvent(*this); }; + agi::Exception *Copy() const override { return new SubtitlesProviderErrorEvent(*this); }; SubtitlesProviderErrorEvent(std::string const& msg); }; diff --git a/aegisub/src/toolbar.cpp b/aegisub/src/toolbar.cpp index 34ce877bb..12edfeffd 100644 --- a/aegisub/src/toolbar.cpp +++ b/aegisub/src/toolbar.cpp @@ -104,7 +104,7 @@ namespace { auto root_it = root.find(name); if (root_it == root.end()) { // Toolbar names are all hardcoded so this should never happen - throw agi::InternalError("Toolbar named " + name + " not found.", 0); + throw agi::InternalError("Toolbar named " + name + " not found.", nullptr); } json::Array const& arr = root_it->second; @@ -164,11 +164,11 @@ namespace { } public: - Toolbar(wxWindow *parent, std::string const& name, agi::Context *c, std::string const& ht_context, bool vertical) - : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT | (vertical ? wxTB_VERTICAL : wxTB_HORIZONTAL)) - , name(name) + Toolbar(wxWindow *parent, std::string name, agi::Context *c, std::string ht_context, bool vertical) + : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT | (vertical ? wxTB_VERTICAL : wxTB_HORIZONTAL)) + , name(std::move(name)) , context(c) - , ht_context(ht_context) + , ht_context(std::move(ht_context)) , icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt()) , icon_size_slot(OPT_SUB("App/Toolbar Icon Size", &Toolbar::OnIconSizeChange, this)) , hotkeys_changed_slot(hotkey::inst->AddHotkeyChangeListener(&Toolbar::RegenerateToolbar, this)) @@ -177,11 +177,11 @@ namespace { Bind(wxEVT_COMMAND_TOOL_CLICKED, &Toolbar::OnClick, this); } - Toolbar(wxFrame *parent, std::string const& name, agi::Context *c, std::string const& ht_context) + Toolbar(wxFrame *parent, std::string name, agi::Context *c, std::string ht_context) : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_HORIZONTAL) - , name(name) + , name(std::move(name)) , context(c) - , ht_context(ht_context) + , ht_context(std::move(ht_context)) #ifndef __WXMAC__ , icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt()) , icon_size_slot(OPT_SUB("App/Toolbar Icon Size", &Toolbar::OnIconSizeChange, this)) diff --git a/aegisub/src/validators.cpp b/aegisub/src/validators.cpp index a6cc80261..dc8cfa5ef 100644 --- a/aegisub/src/validators.cpp +++ b/aegisub/src/validators.cpp @@ -162,7 +162,7 @@ bool StringBinder::TransferFromWindow() { else if (wxComboBox *ctrl = dynamic_cast(window)) *value = from_wx(ctrl->GetValue()); else - throw agi::InternalError("Unsupported control type", 0); + throw agi::InternalError("Unsupported control type", nullptr); return true; } @@ -173,6 +173,6 @@ bool StringBinder::TransferToWindow() { else if (wxComboBox *ctrl = dynamic_cast(window)) ctrl->SetValue(to_wx(*value)); else - throw agi::InternalError("Unsupported control type", 0); + throw agi::InternalError("Unsupported control type", nullptr); return true; } diff --git a/aegisub/src/validators.h b/aegisub/src/validators.h index 4b951b718..2839dee89 100644 --- a/aegisub/src/validators.h +++ b/aegisub/src/validators.h @@ -70,7 +70,7 @@ class EnumBinder : public wxValidator { if (wxRadioBox *rb = dynamic_cast(GetWindow())) *value = static_cast(rb->GetSelection()); else - throw agi::InternalError("Control type not supported by EnumBinder", 0); + throw agi::InternalError("Control type not supported by EnumBinder", nullptr); return true; } @@ -78,7 +78,7 @@ class EnumBinder : public wxValidator { if (wxRadioBox *rb = dynamic_cast(GetWindow())) rb->SetSelection(static_cast(*value)); else - throw agi::InternalError("Control type not supported by EnumBinder", 0); + throw agi::InternalError("Control type not supported by EnumBinder", nullptr); return true; } @@ -95,10 +95,10 @@ EnumBinder MakeEnumBinder(T *value) { class StringBinder : public wxValidator { std::string *value; - wxObject* Clone() const { return new StringBinder(value); } - bool Validate(wxWindow*) { return true;} - bool TransferToWindow(); - bool TransferFromWindow(); + wxObject* Clone() const override { return new StringBinder(value); } + bool Validate(wxWindow*) override { return true;} + bool TransferToWindow() override; + bool TransferFromWindow() override; public: explicit StringBinder(std::string *value) : value(value) { } diff --git a/aegisub/src/vector2d.cpp b/aegisub/src/vector2d.cpp index 842087e62..8ee263483 100644 --- a/aegisub/src/vector2d.cpp +++ b/aegisub/src/vector2d.cpp @@ -77,7 +77,7 @@ Vector2D Vector2D::Round(float step) const { } Vector2D::operator unspecified_bool_type() const { - return *this == Vector2D() ? 0 : &Vector2D::x; + return *this == Vector2D() ? nullptr : &Vector2D::x; } std::string Vector2D::PStr(char sep) const { diff --git a/aegisub/src/video_box.cpp b/aegisub/src/video_box.cpp index df9310ad0..5b3a77f8d 100644 --- a/aegisub/src/video_box.cpp +++ b/aegisub/src/video_box.cpp @@ -61,7 +61,7 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached, agi::Context *context) , context(context) { // Seek - VideoSlider *videoSlider = new VideoSlider(this, context); + auto videoSlider = new VideoSlider(this, context); videoSlider->SetToolTip(_("Seek video")); // Buttons @@ -87,7 +87,7 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached, agi::Context *context) // Visual controls sub-toolbar wxToolBar *visualSubToolBar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_VERTICAL | wxTB_BOTTOM | wxTB_FLAT); - VideoDisplay *videoDisplay = new VideoDisplay(visualSubToolBar, isDetached, zoomBox, this, context); + auto videoDisplay = new VideoDisplay(visualSubToolBar, isDetached, zoomBox, this, context); videoDisplay->MoveBeforeInTabOrder(videoSlider); wxSizer *toolbarSizer = new wxBoxSizer(wxVERTICAL); diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 0ca56f190..26a695ac1 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -80,8 +80,8 @@ public: OpenGlException(const char *func, int err) : agi::Exception(from_wx(wxString::Format("%s failed with error code %d", func, err))) { } - const char * GetName() const { return "video/opengl"; } - Exception * Copy() const { return new OpenGlException(*this); } + const char * GetName() const override { return "video/opengl"; } + Exception * Copy() const override { return new OpenGlException(*this); } }; #define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(#cmd, err) @@ -249,8 +249,8 @@ void VideoDisplay::DrawOverscanMask(float horizontal_percent, float vertical_per // Shift to compensate for black bars Vector2D pos(viewport_left, viewport_top); - for (size_t i = 0; i < 4; ++i) - corners[i] = corners[i] + pos; + for (auto& corner : corners) + corner = corner + pos; int count = 0; std::vector points; diff --git a/aegisub/src/video_out_gl.h b/aegisub/src/video_out_gl.h index 18f649129..39abe4a35 100644 --- a/aegisub/src/video_out_gl.h +++ b/aegisub/src/video_out_gl.h @@ -94,8 +94,8 @@ public: VideoOutRenderException(const char *func, int err) : VideoOutException(std::string(func) + " failed with error code " + std::to_string(err)) { } - const char * GetName() const { return "videoout/opengl/render"; } - Exception * Copy() const { return new VideoOutRenderException(*this); } + const char * GetName() const override { return "videoout/opengl/render"; } + Exception * Copy() const override { return new VideoOutRenderException(*this); } }; /// @class VideoOutOpenGLException /// @extends VideoOutException @@ -106,6 +106,6 @@ public: : VideoOutException(std::string(func) + " failed with error code " + std::to_string(err)) { } VideoOutInitException(const char *err) : VideoOutException(err) { } - const char * GetName() const { return "videoout/opengl/init"; } - Exception * Copy() const { return new VideoOutInitException(*this); } + const char * GetName() const override { return "videoout/opengl/init"; } + Exception * Copy() const override { return new VideoOutInitException(*this); } }; diff --git a/aegisub/src/video_provider_cache.h b/aegisub/src/video_provider_cache.h index 3791560e5..ad56fcceb 100644 --- a/aegisub/src/video_provider_cache.h +++ b/aegisub/src/video_provider_cache.h @@ -39,15 +39,15 @@ public: VideoProviderCache(std::unique_ptr master); ~VideoProviderCache(); - std::shared_ptr GetFrame(int n); + std::shared_ptr GetFrame(int n) override; - int GetFrameCount() const { return master->GetFrameCount(); } - int GetWidth() const { return master->GetWidth(); } - int GetHeight() const { return master->GetHeight(); } - double GetDAR() const { return master->GetDAR(); } - agi::vfr::Framerate GetFPS() const { return master->GetFPS(); } - std::vector GetKeyFrames() const { return master->GetKeyFrames(); } - std::string GetWarning() const { return master->GetWarning(); } - std::string GetDecoderName() const { return master->GetDecoderName(); } - std::string GetColorSpace() const { return master->GetColorSpace(); } + int GetFrameCount() const override { return master->GetFrameCount(); } + int GetWidth() const override { return master->GetWidth(); } + int GetHeight() const override { return master->GetHeight(); } + double GetDAR() const override { return master->GetDAR(); } + agi::vfr::Framerate GetFPS() const override { return master->GetFPS(); } + std::vector GetKeyFrames() const override { return master->GetKeyFrames(); } + std::string GetWarning() const override { return master->GetWarning(); } + std::string GetDecoderName() const override { return master->GetDecoderName(); } + std::string GetColorSpace() const override { return master->GetColorSpace(); } }; diff --git a/aegisub/src/video_provider_dummy.h b/aegisub/src/video_provider_dummy.h index d29658d2c..d2034bb47 100644 --- a/aegisub/src/video_provider_dummy.h +++ b/aegisub/src/video_provider_dummy.h @@ -78,14 +78,14 @@ public: /// string will result in a video with the given parameters static std::string MakeFilename(double fps, int frames, int width, int height, agi::Color colour, bool pattern); - std::shared_ptr GetFrame(int n); + std::shared_ptr GetFrame(int n) override; - int GetFrameCount() const { return framecount; } - int GetWidth() const { return width; } - int GetHeight() const { return height; } - double GetDAR() const { return 0; } - agi::vfr::Framerate GetFPS() const { return fps; } - std::vector GetKeyFrames() const { return std::vector(); } - std::string GetColorSpace() const { return "None"; } - std::string GetDecoderName() const { return "Dummy Video Provider"; } + int GetFrameCount() const override { return framecount; } + int GetWidth() const override { return width; } + int GetHeight() const override { return height; } + double GetDAR() const override { return 0; } + agi::vfr::Framerate GetFPS() const override { return fps; } + std::vector GetKeyFrames() const override { return std::vector(); } + std::string GetColorSpace() const override { return "None"; } + std::string GetDecoderName() const override { return "Dummy Video Provider"; } }; diff --git a/aegisub/src/video_provider_ffmpegsource.h b/aegisub/src/video_provider_ffmpegsource.h index 9222a5e1a..11db850f4 100644 --- a/aegisub/src/video_provider_ffmpegsource.h +++ b/aegisub/src/video_provider_ffmpegsource.h @@ -58,16 +58,16 @@ class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider { public: FFmpegSourceVideoProvider(agi::fs::path const& filename, std::string const& colormatrix); - std::shared_ptr GetFrame(int n); + std::shared_ptr GetFrame(int n) override; - int GetFrameCount() const { return VideoInfo->NumFrames; } - int GetWidth() const { return Width; } - int GetHeight() const { return Height; } - double GetDAR() const { return DAR; } - agi::vfr::Framerate GetFPS() const { return Timecodes; } - std::string GetColorSpace() const { return ColorSpace; } - std::vector GetKeyFrames() const { return KeyFramesList; }; - std::string GetDecoderName() const { return "FFmpegSource"; } - bool WantsCaching() const { return true; } + int GetFrameCount() const override { return VideoInfo->NumFrames; } + int GetWidth() const override { return Width; } + int GetHeight() const override { return Height; } + double GetDAR() const override { return DAR; } + agi::vfr::Framerate GetFPS() const override { return Timecodes; } + std::string GetColorSpace() const override { return ColorSpace; } + std::vector GetKeyFrames() const override { return KeyFramesList; }; + std::string GetDecoderName() const override { return "FFmpegSource"; } + bool WantsCaching() const override { return true; } }; #endif /* WITH_FFMS2 */ diff --git a/aegisub/src/video_provider_yuv4mpeg.h b/aegisub/src/video_provider_yuv4mpeg.h index efd3413cb..ab40c2fa0 100644 --- a/aegisub/src/video_provider_yuv4mpeg.h +++ b/aegisub/src/video_provider_yuv4mpeg.h @@ -132,15 +132,15 @@ public: YUV4MPEGVideoProvider(agi::fs::path const& filename, std::string const&); ~YUV4MPEGVideoProvider(); - std::shared_ptr GetFrame(int n); + std::shared_ptr GetFrame(int n) override; - int GetFrameCount() const { return num_frames; } - int GetWidth() const { return w; } - int GetHeight() const { return h; } - double GetDAR() const { return 0; } - agi::vfr::Framerate GetFPS() const { return fps; } - std::vector GetKeyFrames() const { return std::vector(); } - std::string GetColorSpace() const { return "TV.601"; } - std::string GetDecoderName() const { return "YU4MPEG"; } - bool WantsCaching() const { return true; } + int GetFrameCount() const override { return num_frames; } + int GetWidth() const override { return w; } + int GetHeight() const override { return h; } + double GetDAR() const override { return 0; } + agi::vfr::Framerate GetFPS() const override { return fps; } + std::vector GetKeyFrames() const override { return std::vector(); } + std::string GetColorSpace() const override { return "TV.601"; } + std::string GetDecoderName() const override { return "YU4MPEG"; } + bool WantsCaching() const override { return true; } }; diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 82c87105d..770faab8e 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -54,7 +54,7 @@ VisualToolBase::VisualToolBase(VideoDisplay *parent, agi::Context *context) : c(context) , parent(parent) , holding(false) -, active_line(0) +, active_line(nullptr) , dragging(false) , frame_number(c->videoController->GetFrameN()) , shift_down(false) @@ -110,7 +110,7 @@ void VisualToolBase::OnMouseCaptureLost(wxMouseCaptureLostEvent &) { void VisualToolBase::OnActiveLineChanged(AssDialogue *new_line) { if (!IsDisplayed(new_line)) - new_line = 0; + new_line = nullptr; holding = false; dragging = false; @@ -142,7 +142,7 @@ AssDialogue* VisualToolBase::GetActiveDialogueLine() { AssDialogue *diag = c->selectionController->GetActiveLine(); if (IsDisplayed(diag)) return diag; - return 0; + return nullptr; } void VisualToolBase::SetDisplayArea(int x, int y, int w, int h) { @@ -351,7 +351,7 @@ static param_vec find_tag(boost::ptr_vector& blocks, std::stri } } - return 0; + return nullptr; } // Get a Vector2D from the given tag parameters, or Vector2D::Bad() if they are not valid diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 0b3fbde9c..01632f3e6 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -196,7 +196,7 @@ protected: public: /// @brief Handler for all mouse events /// @param event Shockingly enough, the mouse event - void OnMouseEvent(wxMouseEvent &event); + void OnMouseEvent(wxMouseEvent &event) override; /// @brief Constructor /// @param parent The VideoDisplay to use for coordinate conversion diff --git a/aegisub/src/visual_tool_clip.cpp b/aegisub/src/visual_tool_clip.cpp index 8cef3258f..ad9965a89 100644 --- a/aegisub/src/visual_tool_clip.cpp +++ b/aegisub/src/visual_tool_clip.cpp @@ -37,9 +37,9 @@ VisualToolClip::VisualToolClip(VideoDisplay *parent, agi::Context *context) , inverse(false) { ClipCorner *feats[4]; - for (size_t i = 0; i < 4; ++i) { - feats[i] = new ClipCorner; - features.push_back(*feats[i]); + for (auto& feat : feats) { + feat = new ClipCorner; + features.push_back(*feat); } // Attach each feature to the two features it shares edges with diff --git a/aegisub/src/visual_tool_clip.h b/aegisub/src/visual_tool_clip.h index 96f744a90..443def1ed 100644 --- a/aegisub/src/visual_tool_clip.h +++ b/aegisub/src/visual_tool_clip.h @@ -26,7 +26,7 @@ struct ClipCorner : public VisualDraggableFeature { ClipCorner *horiz; ///< Other corner on this corner's horizontal line ClipCorner *vert; ///< Other corner on this corner's vertical line - ClipCorner() : VisualDraggableFeature() , horiz(0) , vert(0) { type = DRAG_SMALL_CIRCLE; } + ClipCorner() : VisualDraggableFeature() , horiz(nullptr) , vert(nullptr) { type = DRAG_SMALL_CIRCLE; } }; class VisualToolClip : public VisualTool { @@ -35,17 +35,17 @@ class VisualToolClip : public VisualTool { bool inverse; ///< Is this currently in iclip mode? - bool InitializeHold(); - void UpdateHold(); + bool InitializeHold() override; + void UpdateHold() override; void CommitHold(); - void DoRefresh(); + void DoRefresh() override; void SetFeaturePositions(); - bool InitializeDrag(ClipCorner *feature) { return true; } - void UpdateDrag(ClipCorner *feature); + bool InitializeDrag(ClipCorner *feature) override { return true; } + void UpdateDrag(ClipCorner *feature) override; - void Draw(); + void Draw() override; public: VisualToolClip(VideoDisplay *parent, agi::Context *context); }; diff --git a/aegisub/src/visual_tool_cross.h b/aegisub/src/visual_tool_cross.h index 922c47b1d..0657d6e37 100644 --- a/aegisub/src/visual_tool_cross.h +++ b/aegisub/src/visual_tool_cross.h @@ -32,8 +32,8 @@ class OpenGLText; class VisualToolCross : public VisualTool { std::unique_ptr gl_text; - void OnDoubleClick(); - void Draw(); + void OnDoubleClick() override; + void Draw() override; std::string Text(Vector2D v); public: VisualToolCross(VideoDisplay *parent, agi::Context *context); diff --git a/aegisub/src/visual_tool_drag.cpp b/aegisub/src/visual_tool_drag.cpp index a8b97e84a..7eacf62e6 100644 --- a/aegisub/src/visual_tool_drag.cpp +++ b/aegisub/src/visual_tool_drag.cpp @@ -112,7 +112,7 @@ void VisualToolDrag::OnFileChanged() { /// @todo it should be possible to preserve the selection in some cases features.clear(); sel_features.clear(); - primary = 0; + primary = nullptr; active_feature = nullptr; for (auto diag : c->ass->Line | agi::of_type()) { @@ -125,7 +125,7 @@ void VisualToolDrag::OnFileChanged() { void VisualToolDrag::OnFrameChanged() { if (primary && !IsDisplayed(primary->line)) - primary = 0; + primary = nullptr; auto feat = features.begin(); auto end = features.end(); diff --git a/aegisub/src/visual_tool_drag.h b/aegisub/src/visual_tool_drag.h index 464540f2c..461e9909d 100644 --- a/aegisub/src/visual_tool_drag.h +++ b/aegisub/src/visual_tool_drag.h @@ -59,20 +59,20 @@ class VisualToolDrag : public VisualTool { void OnSelectedSetChanged(SubtitleSelection const& lines_added, SubtitleSelection const& lines_removed); - void OnFrameChanged(); - void OnFileChanged(); - void OnLineChanged(); - void OnCoordinateSystemsChanged() { OnFileChanged(); } + void OnFrameChanged() override; + void OnFileChanged() override; + void OnLineChanged() override; + void OnCoordinateSystemsChanged() override { OnFileChanged(); } - bool InitializeDrag(Feature *feature); - void UpdateDrag(Feature *feature); - void Draw(); - void OnDoubleClick(); + bool InitializeDrag(Feature *feature) override; + void UpdateDrag(Feature *feature) override; + void Draw() override; + void OnDoubleClick() override; /// Set the pos/move button to the correct icon based on the active line void UpdateToggleButtons(); void OnSubTool(wxCommandEvent &event); public: VisualToolDrag(VideoDisplay *parent, agi::Context *context); - void SetToolbar(wxToolBar *tb); + void SetToolbar(wxToolBar *tb) override; }; diff --git a/aegisub/src/visual_tool_rotatexy.h b/aegisub/src/visual_tool_rotatexy.h index 7b2a12c5c..4df6a93ff 100644 --- a/aegisub/src/visual_tool_rotatexy.h +++ b/aegisub/src/visual_tool_rotatexy.h @@ -32,11 +32,11 @@ class VisualToolRotateXY : public VisualTool { Feature *org; - void DoRefresh(); - void Draw(); - void UpdateDrag(Feature *feature); - bool InitializeHold(); - void UpdateHold(); + void DoRefresh() override; + void Draw() override; + void UpdateDrag(Feature *feature) override; + bool InitializeHold() override; + void UpdateHold() override; public: VisualToolRotateXY(VideoDisplay *parent, agi::Context *context); }; diff --git a/aegisub/src/visual_tool_rotatez.h b/aegisub/src/visual_tool_rotatez.h index 753148333..336e9720d 100644 --- a/aegisub/src/visual_tool_rotatez.h +++ b/aegisub/src/visual_tool_rotatez.h @@ -33,14 +33,14 @@ class VisualToolRotateZ : public VisualTool { Feature *org; ///< The origin feature - bool InitializeHold(); - void UpdateHold(); + bool InitializeHold() override; + void UpdateHold() override; - void UpdateDrag(Feature *feature); + void UpdateDrag(Feature *feature) override; - void DoRefresh(); + void DoRefresh() override; - void Draw(); + void Draw() override; public: VisualToolRotateZ(VideoDisplay *parent, agi::Context *context); }; diff --git a/aegisub/src/visual_tool_scale.h b/aegisub/src/visual_tool_scale.h index 4b8b9989a..1cb069344 100644 --- a/aegisub/src/visual_tool_scale.h +++ b/aegisub/src/visual_tool_scale.h @@ -31,11 +31,11 @@ class VisualToolScale : public VisualTool { float ry; ///< Y rotation float rz; ///< Z rotation - bool InitializeHold(); - void UpdateHold(); + bool InitializeHold() override; + void UpdateHold() override; - void DoRefresh(); - void Draw(); + void DoRefresh() override; + void Draw() override; public: VisualToolScale(VideoDisplay *parent, agi::Context *context); }; diff --git a/aegisub/src/visual_tool_vector_clip.h b/aegisub/src/visual_tool_vector_clip.h index 1537acad6..11cd541a6 100644 --- a/aegisub/src/visual_tool_vector_clip.h +++ b/aegisub/src/visual_tool_vector_clip.h @@ -59,15 +59,15 @@ class VisualToolVectorClip : public VisualTool names = GetEncodingsList >(); - for (std::vector::iterator cur = names.begin(); cur != names.end(); ++cur) { + for (auto cur = names.begin(); cur != names.end(); ++cur) { ASSERT_NO_THROW(IconvWrapper("utf-8", cur->c_str())); ASSERT_NO_THROW(IconvWrapper(cur->c_str(), "utf-8")); EXPECT_EQ( diff --git a/aegisub/tests/tests/line_iterator.cpp b/aegisub/tests/tests/line_iterator.cpp index 83d0df366..b719e6b7b 100644 --- a/aegisub/tests/tests/line_iterator.cpp +++ b/aegisub/tests/tests/line_iterator.cpp @@ -56,26 +56,26 @@ void expect_eq(const char (&str)[N], const char *charset, int num, ...) { TEST(lagi_line, int) { std::vector charsets = agi::charset::GetEncodingsList >(); - for (std::vector::iterator cur = charsets.begin(); cur != charsets.end(); ++cur) { - expect_eq("1\n2\n3\n4", cur->c_str(), 4, 1, 2, 3, 4); - expect_eq("1\n2\n3\n4\n", cur->c_str(), 4, 1, 2, 3, 4); - expect_eq("1\n2\nb\n3\n4", cur->c_str(), 4, 1, 2, 3, 4); - expect_eq("1.0\n2.0\n3.0\n4.0", cur->c_str(), 4, 1, 2, 3, 4); - expect_eq(" 0x16 \n 09 \n -2", cur->c_str(), 3, 0, 9, -2); + for (auto const& charset : charsets) { + expect_eq("1\n2\n3\n4", charset.c_str(), 4, 1, 2, 3, 4); + expect_eq("1\n2\n3\n4\n", charset.c_str(), 4, 1, 2, 3, 4); + expect_eq("1\n2\nb\n3\n4", charset.c_str(), 4, 1, 2, 3, 4); + expect_eq("1.0\n2.0\n3.0\n4.0", charset.c_str(), 4, 1, 2, 3, 4); + expect_eq(" 0x16 \n 09 \n -2", charset.c_str(), 3, 0, 9, -2); } } TEST(lagi_line, double) { std::vector charsets = agi::charset::GetEncodingsList >(); - for (std::vector::iterator cur = charsets.begin(); cur != charsets.end(); ++cur) { - expect_eq("1.0\n2.0", cur->c_str(), 2, 1.0, 2.0); - expect_eq("#1.0\n\t2.5", cur->c_str(), 1, 2.5); + for (auto const& charset : charsets) { + expect_eq("1.0\n2.0", charset.c_str(), 2, 1.0, 2.0); + expect_eq("#1.0\n\t2.5", charset.c_str(), 1, 2.5); } } TEST(lagi_line, string) { std::vector charsets = agi::charset::GetEncodingsList >(); - for (std::vector::iterator cur = charsets.begin(); cur != charsets.end(); ++cur) { - expect_eq("line 1\nline 2\nline 3", cur->c_str(), 3, "line 1", "line 2", "line 3"); - expect_eq(" white space ", cur->c_str(), 1, " white space "); - expect_eq("blank\n\nlines\n", cur->c_str(), 4, "blank", "", "lines", ""); + for (auto const& charset : charsets) { + expect_eq("line 1\nline 2\nline 3", charset.c_str(), 3, "line 1", "line 2", "line 3"); + expect_eq(" white space ", charset.c_str(), 1, " white space "); + expect_eq("blank\n\nlines\n", charset.c_str(), 4, "blank", "", "lines", ""); } } diff --git a/aegisub/tests/tests/mru.cpp b/aegisub/tests/tests/mru.cpp index 803d2ffcb..86648b4db 100644 --- a/aegisub/tests/tests/mru.cpp +++ b/aegisub/tests/tests/mru.cpp @@ -22,7 +22,7 @@ protected: std::string default_mru; std::string conf_ok; - void SetUp() { + void SetUp() override { default_mru = "{\"Valid\" : []}"; conf_ok = "./data/mru_ok.json"; } @@ -105,7 +105,7 @@ TEST_F(lagi_mru, MRUEntryRemove_r4347) { EXPECT_NO_THROW(mru.Remove("Valid", "/path/to/file")); const agi::MRUManager::MRUListMap *map_list = mru.Get("Valid"); - agi::MRUManager::MRUListMap::const_iterator i_lst = map_list->begin(); + auto i_lst = map_list->begin(); if ((i_lst != map_list->end()) && (*i_lst == "/path/to/file")) FAIL() << "r4347 regression, Entry exists after remove"; diff --git a/aegisub/tests/tests/option.cpp b/aegisub/tests/tests/option.cpp index a2d93fb5d..22f777457 100644 --- a/aegisub/tests/tests/option.cpp +++ b/aegisub/tests/tests/option.cpp @@ -26,7 +26,7 @@ protected: std::string default_opt; std::string conf_ok; - void SetUp() { + void SetUp() override { default_opt = "{\"Valid\" : \"This is valid\"}"; conf_ok = "data/options/string.json"; } diff --git a/aegisub/tests/tests/syntax_highlight.cpp b/aegisub/tests/tests/syntax_highlight.cpp index 4295f3eaf..e17ded506 100644 --- a/aegisub/tests/tests/syntax_highlight.cpp +++ b/aegisub/tests/tests/syntax_highlight.cpp @@ -18,13 +18,13 @@ #include "main.h" class MockSpellChecker : public agi::SpellChecker { - void AddWord(std::string const&) { } - void RemoveWord(std::string const&) { } - bool CanAddWord(std::string const&) { return false; } - bool CanRemoveWord(std::string const&) { return false; } - std::vector GetSuggestions(std::string const&) { return std::vector(); } - std::vector GetLanguageList() { return std::vector(); } - bool CheckWord(std::string const& word) { return word != "incorrect"; } + void AddWord(std::string const&) override { } + void RemoveWord(std::string const&) override { } + bool CanAddWord(std::string const&) override { return false; } + bool CanRemoveWord(std::string const&) override { return false; } + std::vector GetSuggestions(std::string const&) override { return std::vector(); } + std::vector GetLanguageList() override { return std::vector(); } + bool CheckWord(std::string const& word) override { return word != "incorrect"; } }; using namespace agi::ass; @@ -37,10 +37,10 @@ TEST(lagi_syntax, empty) { std::string text; std::vector tokens; - EXPECT_TRUE(SyntaxHighlight(text, tokens, 0).empty()); + EXPECT_TRUE(SyntaxHighlight(text, tokens, nullptr).empty()); tokens.emplace_back(dt::TEXT, 0); - auto syntax = SyntaxHighlight(text, tokens, 0); + auto syntax = SyntaxHighlight(text, tokens, nullptr); EXPECT_EQ(1u, syntax.size()); EXPECT_EQ(ss::NORMAL, syntax[0].type); } diff --git a/aegisub/tests/tests/thesaurus.cpp b/aegisub/tests/tests/thesaurus.cpp index 9988c1e21..194149464 100644 --- a/aegisub/tests/tests/thesaurus.cpp +++ b/aegisub/tests/tests/thesaurus.cpp @@ -25,7 +25,7 @@ protected: std::string idx_path; std::string dat_path; - void SetUp() { + void SetUp() override { using std::endl; idx_path = "data/thes.idx";