From 26ce77ded5afa1de9709d5c06912f3c879805dec Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 21 May 2018 17:07:24 +0800 Subject: [PATCH 1/2] fix compiler errors which caused by support of freebsd --- source/audio/detail/audio_device.cpp | 33 ++++++++++++++-------------- source/system/platform.cpp | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/source/audio/detail/audio_device.cpp b/source/audio/detail/audio_device.cpp index f191a302..73a0ee8b 100644 --- a/source/audio/detail/audio_device.cpp +++ b/source/audio/detail/audio_device.cpp @@ -12,7 +12,9 @@ #include #include - static bool get_default_audio(std::string &, bool); +# ifndef NANA_LINUX + static bool get_default_audio(std::string &, bool); +# endif #endif namespace nana{namespace audio @@ -47,14 +49,13 @@ namespace nana{namespace audio }wave_native_if; #endif //class audio_device - audio_device::audio_device() -#if defined(NANA_WINDOWS) - : handle_(nullptr), buf_prep_(nullptr) + audio_device::audio_device(): +#if defined(NANA_WINDOWS) || defined(NANA_LINUX) + handle_(nullptr), #elif defined(NANA_POSIX) - : handle_(-1), buf_prep_(nullptr) -#elif defined(NANA_LINUX) - : handle_(nullptr), buf_prep_(nullptr) + handle_(-1), #endif + buf_prep_(nullptr) {} audio_device::~audio_device() @@ -64,11 +65,11 @@ namespace nana{namespace audio bool audio_device::empty() const { - #ifdef NANA_POSIX +#if defined(NANA_POSIX) && not defined(NANA_LINUX) return (-1 == handle_); - #else +#else return (nullptr == handle_); - #endif +#endif } bool audio_device::open(std::size_t channels, std::size_t rate, std::size_t bits_per_sample) @@ -249,11 +250,6 @@ namespace nana{namespace audio wave_native_if.out_prepare(handle_, m, sizeof(WAVEHDR)); wave_native_if.out_write(handle_, m, sizeof(WAVEHDR)); -#elif defined(NANA_POSIX) - // consider moving this to a background thread. - // currently this blocks calling thread. - ::write(handle_, m->buf, m->bufsize); - buf_prep_->revert(m); #elif defined(NANA_LINUX) std::size_t frames = m->bufsize / bytes_per_frame_; std::size_t buffered = 0; //in bytes @@ -269,6 +265,11 @@ namespace nana{namespace audio ::snd_pcm_prepare(handle_); } buf_prep_->revert(m); +#elif defined(NANA_POSIX) + // consider moving this to a background thread. + // currently this blocks calling thread. + ::write(handle_, m->buf, m->bufsize); + buf_prep_->revert(m); #endif } @@ -304,7 +305,7 @@ namespace nana{namespace audio }//end namespace audio }//end namespace nana -#ifdef NANA_POSIX +#if defined(NANA_POSIX) && not defined(NANA_LINUX) // parse input securely, no-overruns or overflows. static bool match(char *&cursor, const char *pattern, const char *tail) { diff --git a/source/system/platform.cpp b/source/system/platform.cpp index 107d26f7..d8832c68 100644 --- a/source/system/platform.cpp +++ b/source/system/platform.cpp @@ -34,7 +34,7 @@ static void posix_open_url(const char *url_utf8) const char *home = getenv("HOME"); std::string cheat(home); cheat += "/.mozilla"; - struct stat exists{}; + struct stat exists; // TODO: generalize this for chromium, opera, waterfox, etc. // Most desktop environments (KDE, Gnome, Lumina etc.) provide a way to set From 216cb786e76d1457296e0f0ee5aabdebdf6fa7eb Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 22 May 2018 14:22:58 +0800 Subject: [PATCH 2/2] various fixes fixed compiler warnings fixed bad overridings fixed FreeBSD support --- CMakeLists.txt | 6 +++++- include/nana/gui/widgets/listbox.hpp | 2 +- include/nana/gui/widgets/textbox.hpp | 2 +- include/nana/gui/widgets/treebox.hpp | 2 +- source/gui/place.cpp | 7 ++++--- source/gui/widgets/textbox.cpp | 2 +- source/gui/widgets/treebox.cpp | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fbeb363..1d023469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,7 +142,11 @@ endif() # if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall") + if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") + set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall -I/usr/local/include") + else() + set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall") + endif() else() set(CMAKE_CXX_FLAGS "-std=c++14 -Wall") endif() diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 3f2caab6..1fe6aeca 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -1541,7 +1541,7 @@ the nana::detail::basic_window member pointer scheme nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const override; drawerbase::listbox::category_t* _m_assoc(std::shared_ptr, bool create_if_not_exists); void _m_erase_key(nana::detail::key_interface*) noexcept; - std::shared_ptr _m_scroll_operation(); + std::shared_ptr _m_scroll_operation() override; }; }//end namespace nana diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index de70728c..4a2663ae 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -279,7 +279,7 @@ namespace nana native_string_type _m_caption() const throw() override; void _m_caption(native_string_type&&) override; void _m_typeface(const paint::font&) override; - std::shared_ptr _m_scroll_operation() const; + std::shared_ptr _m_scroll_operation() override; }; }//end namespace nana #include diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index 75be5da0..671851c2 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -446,7 +446,7 @@ namespace nana item_proxy selected() const; ///< returns the selected node private: - std::shared_ptr _m_scroll_operation() const; + std::shared_ptr _m_scroll_operation() override; };//end class treebox }//end namespace nana diff --git a/source/gui/place.cpp b/source/gui/place.cpp index f8fb949a..5a9982c6 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -2583,8 +2583,9 @@ namespace nana : public division { public: - div_switchable(std::string && name, implement* impl) noexcept - : division(kind::switchable, std::move(name)), impl_(impl) + div_switchable(std::string && name, implement* /*impl*/) noexcept: + division(kind::switchable, std::move(name))//, + //impl_(impl) //deprecated {} private: void collocate(window wd) override @@ -2613,7 +2614,7 @@ namespace nana } } private: - implement * const impl_; + //implement * const impl_; //deprecated }; place::implement::~implement() diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 265a8e28..2fbc9290 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -817,7 +817,7 @@ namespace drawerbase { editor->reset_caret_pixels(); } - std::shared_ptr textbox::_m_scroll_operation() const + std::shared_ptr textbox::_m_scroll_operation() { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 4dcf0d57..19873e27 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -2234,7 +2234,7 @@ namespace nana return item_proxy(const_cast(&get_drawer_trigger()), get_drawer_trigger().selected()); } - std::shared_ptr treebox::_m_scroll_operation() const + std::shared_ptr treebox::_m_scroll_operation() { internal_scope_guard lock; return std::make_shared(get_drawer_trigger().impl()->shape.scroll);