From e91d3446eb3cc908444ed0122ff87511646494a2 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 9 Aug 2018 07:50:56 +0800 Subject: [PATCH] fix GCC errors when -std=c++17 is specified --- include/nana/gui/detail/general_events.hpp | 4 +- source/gui/detail/native_window_interface.cpp | 5 +- source/paint/graphics.cpp | 55 ++++++++++--------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/include/nana/gui/detail/general_events.hpp b/include/nana/gui/detail/general_events.hpp index 0a4881b4..9a9496e2 100644 --- a/include/nana/gui/detail/general_events.hpp +++ b/include/nana/gui/detail/general_events.hpp @@ -172,7 +172,7 @@ namespace nana } else if constexpr(std::is_invocable_v) { - return _m_emplace(new docker{ this, [fn](arg_reference){ + return _m_emplace(new docker{ this, [fn](arg_reference) mutable{ fn(); }, false }, false); } @@ -200,7 +200,7 @@ namespace nana } else if constexpr(std::is_invocable_v) { - return _m_emplace(new docker{ this, [fn](arg_reference) { + return _m_emplace(new docker{ this, [fn](arg_reference) mutable{ fn(); }, true }, in_front); } diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 1f683075..d922fe44 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -1384,9 +1384,10 @@ namespace nana{ } else if(window_relationship::owner == rsp) return owner; - - return x11_parent_window(wd); + else if(window_relationship::parent == rsp) + return x11_parent_window(wd); #endif + return nullptr; } native_window_type native_interface::parent_window(native_window_type child, native_window_type new_parent, bool returns_previous) diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index fbf07358..004a34a5 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -498,41 +498,42 @@ namespace paint { if (nullptr == impl_->handle || nullptr == impl_->handle->context) return {}; - if (text.empty()) return std::unique_ptr{new unsigned[1]}; + auto pxbuf = std::unique_ptr{ new unsigned[text.size() ? text.size() : 1] }; - unsigned tab_pixels = impl_->handle->string.tab_length * impl_->handle->string.whitespace_pixels; -#if defined(NANA_WINDOWS) - int * dx = new int[text.size()]; - SIZE extents; - ::GetTextExtentExPoint(impl_->handle->context, text.data(), static_cast(text.size()), 0, 0, dx, &extents); - - auto pxbuf = std::unique_ptr{ new unsigned[text.size()] }; - - pxbuf[0] = (text[0] == '\t' ? tab_pixels : dx[0]); - - for (std::size_t i = 1; i < text.size(); ++i) + if (!text.empty()) { - pxbuf[i] = (text[i] == '\t' ? tab_pixels : dx[i] - dx[i - 1]); - } - delete[] dx; + unsigned tab_pixels = impl_->handle->string.tab_length * impl_->handle->string.whitespace_pixels; +#if defined(NANA_WINDOWS) + int * dx = new int[text.size()]; + SIZE extents; + ::GetTextExtentExPoint(impl_->handle->context, text.data(), static_cast(text.size()), 0, 0, dx, &extents); + + pxbuf[0] = (text[0] == '\t' ? tab_pixels : dx[0]); + + for (std::size_t i = 1; i < text.size(); ++i) + { + pxbuf[i] = (text[i] == '\t' ? tab_pixels : dx[i] - dx[i - 1]); + } + delete[] dx; #elif defined(NANA_X11) && defined(NANA_USE_XFT) - auto disp = nana::detail::platform_spec::instance().open_display(); - auto xft = reinterpret_cast(impl_->handle->font->native_handle()); + auto disp = nana::detail::platform_spec::instance().open_display(); + auto xft = reinterpret_cast(impl_->handle->font->native_handle()); - XGlyphInfo extents; - for (std::size_t i = 0; i < len; ++i) - { - if (text[i] != '\t') + XGlyphInfo extents; + for (std::size_t i = 0; i < text.size(); ++i) { - FT_UInt glyphs = ::XftCharIndex(disp, xft, text[i]); - ::XftGlyphExtents(disp, xft, &glyphs, 1, &extents); - pxbuf[i] = extents.xOff; + if (text[i] != '\t') + { + FT_UInt glyphs = ::XftCharIndex(disp, xft, text[i]); + ::XftGlyphExtents(disp, xft, &glyphs, 1, &extents); + pxbuf[i] = extents.xOff; + } + else + pxbuf[i] = tab_pixels; } - else - pxbuf[i] = tab_pixels; - } #endif + } return pxbuf; }