From c2c44f1ad2e7697d49e5dc59a4833c04f3669a5d Mon Sep 17 00:00:00 2001 From: wangqr Date: Fri, 6 Sep 2019 13:58:56 -0400 Subject: [PATCH] Fix build warnings For pimpl with anonymous namespace, see https://stackoverflow.com/questions/39684438 --- .travis.yml | 2 +- libaegisub/audio/provider_convert.cpp | 8 ++++---- src/audio_display.cpp | 8 +++++--- src/audio_display.h | 7 ++----- src/audio_timing_karaoke.cpp | 2 +- src/auto4_lua_assfile.cpp | 4 ++-- src/colour_button.cpp | 2 +- src/colour_button.h | 2 +- src/dialog_autosave.cpp | 2 +- src/dialog_video_properties.cpp | 3 ++- src/gl_text.cpp | 11 ++++------- src/gl_text.h | 11 ++++------- src/hotkey.cpp | 2 ++ src/resolution_resampler.cpp | 1 + src/subtitles_provider_csri.cpp | 4 ++-- src/validators.cpp | 6 ++++-- 16 files changed, 37 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61faec170..3b0e66813 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ script: ./build/version.sh .; mkdir build-dir; cd build-dir; - cmake -DCMAKE_CXX_FLAGS='-Wall -Wextra -pedantic -std=gnu++11' ..; + cmake -DCMAKE_CXX_FLAGS='-Wall -Wextra -Wno-unused-parameter -pedantic' ..; make -j2; fi diff --git a/libaegisub/audio/provider_convert.cpp b/libaegisub/audio/provider_convert.cpp index b45d8a852..995903e79 100644 --- a/libaegisub/audio/provider_convert.cpp +++ b/libaegisub/audio/provider_convert.cpp @@ -41,14 +41,14 @@ public: void FillBuffer(void *buf, int64_t start, int64_t count64) const override { auto count = static_cast(count64); - assert(count == count64); + assert(count64 >= 0 && count == static_cast(count64)); src_buf.resize(count * src_bytes_per_sample * channels); source->GetAudio(src_buf.data(), start, count); auto dest = static_cast(buf); - for (int64_t i = 0; i < count * channels; ++i) { + for (size_t i = 0; i < count * channels; ++i) { int64_t sample = 0; // 8 bits per sample is assumed to be unsigned with a bias of 127, @@ -85,7 +85,7 @@ public: void FillBuffer(void *buf, int64_t start, int64_t count64) const override { auto count = static_cast(count64); - assert(count == count64); + assert(count64 >= 0 && count == static_cast(count64)); src_buf.resize(count * channels); source->GetAudio(&src_buf[0], start, count); @@ -119,7 +119,7 @@ public: void FillBuffer(void *buf, int64_t start, int64_t count64) const override { auto count = static_cast(count64); - assert(count == count64); + assert(count64 >= 0 && count == static_cast(count64)); src_buf.resize(count * src_channels); source->GetAudio(&src_buf[0], start, count); diff --git a/src/audio_display.cpp b/src/audio_display.cpp index 2041715fd..6548d4814 100644 --- a/src/audio_display.cpp +++ b/src/audio_display.cpp @@ -128,8 +128,9 @@ public: /// Get the current Selection colour wxColour Selection() const { return focused ? sel_focused_colour : sel_colour; } }; +} -class AudioDisplayScrollbar final : public AudioDisplayInteractionObject { +class AudioDisplay::AudioDisplayScrollbar final : public AudioDisplayInteractionObject { static const int height = 15; static const int min_width = 10; @@ -267,9 +268,9 @@ public: } }; -const int AudioDisplayScrollbar::min_width; +const int AudioDisplay::AudioDisplayScrollbar::min_width; -class AudioDisplayTimeline final : public AudioDisplayInteractionObject { +class AudioDisplay::AudioDisplayTimeline final : public AudioDisplayInteractionObject { int duration = 0; ///< Total duration in ms double ms_per_pixel = 1.0; ///< Milliseconds per pixel int pixel_left = 0; ///< Leftmost visible pixel (i.e. scroll position) @@ -478,6 +479,7 @@ public: } }; +namespace { class AudioStyleRangeMerger final : public AudioRenderingStyleRanges { typedef std::map style_map; public: diff --git a/src/audio_display.h b/src/audio_display.h index 4c8e26a5f..04d64d56e 100644 --- a/src/audio_display.h +++ b/src/audio_display.h @@ -47,11 +47,6 @@ class AudioRenderer; class AudioRendererBitmapProvider; class TimeRange; -// Helper classes used in implementation of the audio display -namespace { - class AudioDisplayScrollbar; - class AudioDisplayTimeline; -} class AudioDisplayInteractionObject; class AudioMarkerInteractionObject; @@ -79,9 +74,11 @@ class AudioDisplay: public wxWindow { agi::AudioProvider *provider = nullptr; /// Scrollbar helper object + class AudioDisplayScrollbar; std::unique_ptr scrollbar; /// Timeline helper object + class AudioDisplayTimeline; std::unique_ptr timeline; /// The interaction object for the last-dragged audio marker diff --git a/src/audio_timing_karaoke.cpp b/src/audio_timing_karaoke.cpp index b848ef582..eaf1f91a3 100644 --- a/src/audio_timing_karaoke.cpp +++ b/src/audio_timing_karaoke.cpp @@ -390,7 +390,7 @@ int AudioTimingControllerKaraoke::MoveMarker(KaraokeMarker *marker, int new_posi void AudioTimingControllerKaraoke::AnnounceChanges(int syl) { if (syl < 0) return; - if (syl == cur_syl || syl == cur_syl + 1) { + if (static_cast(syl) == cur_syl || static_cast(syl) == cur_syl + 1) { AnnounceUpdatedPrimaryRange(); AnnounceUpdatedStyleRanges(); } diff --git a/src/auto4_lua_assfile.cpp b/src/auto4_lua_assfile.cpp index 3aef3b769..241bd8722 100644 --- a/src/auto4_lua_assfile.cpp +++ b/src/auto4_lua_assfile.cpp @@ -744,8 +744,8 @@ namespace Automation4 { , can_modify(can_modify) , can_set_undo(can_set_undo) { - for (auto& line : ass->Info) - lines.push_back(nullptr); + // for (auto& line : ass->Info) lines.push_back(nullptr); + lines.insert(lines.end(), ass->Info.size(), nullptr); for (auto& line : ass->Styles) lines.push_back(&line); for (auto& line : ass->Events) diff --git a/src/colour_button.cpp b/src/colour_button.cpp index 83671ebf3..304665f0a 100644 --- a/src/colour_button.cpp +++ b/src/colour_button.cpp @@ -24,7 +24,7 @@ #include #endif -AGI_DEFINE_EVENT(EVT_COLOR, agi::Color); +AGI_DEFINE_EVENT(EVT_COLOR, agi::Color) 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) diff --git a/src/colour_button.h b/src/colour_button.h index 6234dc9fc..0b57ee8cb 100644 --- a/src/colour_button.h +++ b/src/colour_button.h @@ -22,7 +22,7 @@ /// Emitted by ColourButton when the user picks a new color, with the chosen /// color set to the event payload -AGI_DECLARE_EVENT(EVT_COLOR, agi::Color); +AGI_DECLARE_EVENT(EVT_COLOR, agi::Color) /// A button which displays a currently-selected color and lets the user pick /// a new color when clicked diff --git a/src/dialog_autosave.cpp b/src/dialog_autosave.cpp index c5a5f61cb..7b215b390 100644 --- a/src/dialog_autosave.cpp +++ b/src/dialog_autosave.cpp @@ -143,7 +143,7 @@ void DialogAutosave::Populate(std::map &files_map, std:: auto it = files_map.find(name); if (it == files_map.end()) - it = files_map.insert({name, AutosaveFile{name}}).first; + it = files_map.insert({name, AutosaveFile{name, std::vector()}}).first; it->second.versions.push_back(Version{wxFileName(directory, fn).GetFullPath(), date, agi::wxformat(name_fmt, date.Format())}); } while (dir.GetNext(&fn)); } diff --git a/src/dialog_video_properties.cpp b/src/dialog_video_properties.cpp index 90c407844..9b6e59c02 100644 --- a/src/dialog_video_properties.cpp +++ b/src/dialog_video_properties.cpp @@ -131,7 +131,6 @@ bool update_video_properties(AssFile *file, const AsyncVideoProvider *new_provid return true; case MISMATCH_RESAMPLE: - // Fallthrough to prompt if the AR changed if (!ar_changed) { ResampleResolution(file, { {0, 0, 0, 0}, @@ -141,6 +140,8 @@ bool update_video_properties(AssFile *file, const AsyncVideoProvider *new_provid }); return true; } + // Fallthrough + // to prompt if the AR changed case MISMATCH_PROMPT: int res = prompt(parent, ar_changed, sx, sy, vx, vy); diff --git a/src/gl_text.cpp b/src/gl_text.cpp index 94f866961..3786466fb 100644 --- a/src/gl_text.cpp +++ b/src/gl_text.cpp @@ -52,10 +52,9 @@ #include #endif -namespace { /// @class OpenGLTextGlyph /// @brief Struct storing the information needed to draw a glyph -struct OpenGLTextGlyph { +struct OpenGLText::OpenGLTextGlyph { wxString str; ///< String containing the glyph(s) this is for int tex = 0; ///< OpenGL texture to draw for this glyph float x1 = 0; ///< Left x coordinate of this glyph in the containing texture @@ -108,7 +107,7 @@ struct OpenGLTextGlyph { /// @class OpenGLTextTexture /// @brief OpenGL texture which stores one or more glyphs as sprites -class OpenGLTextTexture final : boost::noncopyable { +class OpenGLText::OpenGLTextTexture final : boost::noncopyable { int x = 0; ///< Next x coordinate at which a glyph can be inserted int y = 0; ///< Next y coordinate at which a glyph can be inserted int nextY = 0; ///< Y coordinate of the next line; tracked due to that lines @@ -217,8 +216,6 @@ public: } }; -} - OpenGLText::OpenGLText() { } OpenGLText::~OpenGLText() { } @@ -286,12 +283,12 @@ void OpenGLText::GetExtent(std::string const& text, int &w, int &h) { } } -OpenGLTextGlyph const& OpenGLText::GetGlyph(int i) { +OpenGLText::OpenGLTextGlyph const& OpenGLText::GetGlyph(int i) { auto res = glyphs.find(i); return res != glyphs.end() ? res->second : CreateGlyph(i); } -OpenGLTextGlyph const& OpenGLText::CreateGlyph(int n) { +OpenGLText::OpenGLTextGlyph const& OpenGLText::CreateGlyph(int n) { OpenGLTextGlyph &glyph = glyphs.emplace(n, OpenGLTextGlyph(n, font)).first->second; // Insert into some texture diff --git a/src/gl_text.h b/src/gl_text.h index e25045f12..0ad8f5f95 100644 --- a/src/gl_text.h +++ b/src/gl_text.h @@ -34,16 +34,13 @@ #include -namespace { -struct OpenGLTextGlyph; -class OpenGLTextTexture; -} - namespace agi { struct Color; } -typedef boost::container::map glyphMap; - class OpenGLText { + struct OpenGLTextGlyph; + class OpenGLTextTexture; + typedef boost::container::map glyphMap; + float r = 1.f, g = 1.f, b = 1.f, a = 1.f; int fontSize = 0; diff --git a/src/hotkey.cpp b/src/hotkey.cpp index deb624628..334fbb421 100644 --- a/src/hotkey.cpp +++ b/src/hotkey.cpp @@ -52,10 +52,12 @@ namespace { {nullptr} }; +#ifdef __WXMAC__ const char *added_hotkeys_minimize[][3] = { {"app/minimize", "Default", "Ctrl-M"}, {nullptr} }; +#endif void migrate_hotkeys(const char *added[][3]) { auto hk_map = hotkey::inst->GetHotkeyMap(); diff --git a/src/resolution_resampler.cpp b/src/resolution_resampler.cpp index e5c0b56f9..5bb57fb34 100644 --- a/src/resolution_resampler.cpp +++ b/src/resolution_resampler.cpp @@ -233,6 +233,7 @@ void ResampleResolution(AssFile *ass, ResampleSettings settings) { switch (settings.ar_mode) { case ResampleARMode::RemoveBorder: border_horizontally = !border_horizontally; + // fallthrough case ResampleARMode::AddBorder: if (border_horizontally) // Wider/Shorter settings.margin[LEFT] = settings.margin[RIGHT] = (settings.source_y * new_ar - settings.source_x) / 2; diff --git a/src/subtitles_provider_csri.cpp b/src/subtitles_provider_csri.cpp index 87429e213..b80282bb6 100644 --- a/src/subtitles_provider_csri.cpp +++ b/src/subtitles_provider_csri.cpp @@ -92,7 +92,7 @@ void CSRISubtitlesProvider::DrawSubtitles(VideoFrame &dst, double time) { csri_frame frame; if (dst.flipped) { frame.planes[0] = dst.data.data() + (dst.height-1) * dst.width * 4; - frame.strides[0] = -(signed)dst.width * 4; + frame.strides[0] = -(ptrdiff_t)dst.width * 4; } else { frame.planes[0] = dst.data.data(); @@ -100,7 +100,7 @@ void CSRISubtitlesProvider::DrawSubtitles(VideoFrame &dst, double time) { } frame.pixfmt = CSRI_F_BGR_; - csri_fmt format = { frame.pixfmt, dst.width, dst.height }; + csri_fmt format = { frame.pixfmt, (unsigned)dst.width, (unsigned)dst.height }; std::lock_guard lock(csri_mutex); if (!csri_request_fmt(instance.get(), &format)) diff --git a/src/validators.cpp b/src/validators.cpp index ac6e024a6..b39367f7a 100644 --- a/src/validators.cpp +++ b/src/validators.cpp @@ -47,7 +47,8 @@ IntValidator::IntValidator(int val, bool allow_negative) } IntValidator::IntValidator(IntValidator const& rgt) -: value(rgt.value) +: wxValidator(rgt) +, value(rgt.value) , allow_negative(rgt.allow_negative) { SetWindow(rgt.GetWindow()); @@ -96,7 +97,8 @@ DoubleValidator::DoubleValidator(double *val, double min, double max) } DoubleValidator::DoubleValidator(DoubleValidator const& rgt) -: value(rgt.value) +: wxValidator(rgt) +, value(rgt.value) , min(rgt.min) , max(rgt.max) , decimal_sep(rgt.decimal_sep)