diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-10-25 14:39:53 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-10-25 16:47:35 +0200 |
commit | 4b0f51efbcb9e71034089f431117e6bac92a26b2 (patch) | |
tree | fbcc35c5e571c8803ac615060a4a08cfc9b9f431 /vcl/source/app | |
parent | 4c3bf75187741d19beb4698f13a11cd3c951fb08 (diff) |
Address a constexpr template point of instantiation issue
...that hits at least when building with Clang and --with-latest-c++ against
recent libc++ or MSVC standard library (where C++20 and esp. C++23 made more and
more class template member functions constexpr). My understanding is that there
is some leeway at what point a compiler should instantiate such function
specializations, and Clang decides to instantiate constexpr ones early (cf.
<https://github.com/llvm/llvm-project/commit/242ad89a15d5466d166d47978bfff983d40ab511>
"C++11 half of r147023: In C++11, additionally eagerly instantiate:" and its "Do
not defer instantiations of constexpr functions" comment, and the discussion at
<https://discourse.llvm.org/t/point-of-instantiation-of-constexpr-function-template/65129>).
> In file included from vcl/source/app/salvtables.cxx:26:
> In file included from workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/awt/XWindow.hpp:6:
> In file included from workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/awt/XWindow.hdl:13:
> In file included from workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/lang/XComponent.hdl:7:
> In file included from workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/uno/XInterface.hdl:6:
> In file included from include/com/sun/star/uno/Any.h:30:
> In file included from include/rtl/ustring.hxx:34:
> In file included from ~/llvm/inst/bin/../include/c++/v1/ostream:168:
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:47:19: error: invalid application of 'sizeof' to an incomplete type 'SalFlashAttention'
> static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
> ^~~~~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:281:7: note: in instantiation of member function 'std::default_delete<SalFlashAttention>::operator()' requested here
> __ptr_.second()(__tmp);
> ^
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:247:75: note: in instantiation of member function 'std::unique_ptr<SalFlashAttention>::reset' requested here
> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
> ^
> vcl/source/app/salvtables.cxx:292:20: note: in instantiation of member function 'std::unique_ptr<SalFlashAttention>::~unique_ptr' requested here
> SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder,
> ^
> vcl/inc/salvtables.hxx:172:7: note: forward declaration of 'SalFlashAttention'
> class SalFlashAttention;
> ^
Change-Id: I49523c8db5b3fdd4dc5614fdb5c6f8ced73f5eca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141821
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/source/app')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d4f9b41e329c..7af5cccb4e6b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -241,6 +241,73 @@ void SalMenu::ApplyPersona() {} SalMenuItem::~SalMenuItem() {} +class SalFlashAttention +{ +private: + VclPtr<vcl::Window> m_xWidget; + Timer m_aFlashTimer; + Color m_aOrigControlBackground; + Wallpaper m_aOrigBackground; + bool m_bOrigControlBackground; + int m_nFlashCount; + + void SetFlash() + { + Color aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()); + m_xWidget->SetControlBackground(aColor); + } + + void ClearFlash() + { + if (m_bOrigControlBackground) + m_xWidget->SetControlBackground(m_aOrigControlBackground); + else + m_xWidget->SetControlBackground(); + } + + void Flash() + { + constexpr int FlashesWanted = 1; + + if (m_nFlashCount % 2 == 0) + ClearFlash(); + else + SetFlash(); + + if (m_nFlashCount == FlashesWanted * 2) + return; + + ++m_nFlashCount; + + m_aFlashTimer.Start(); + } + + DECL_LINK(FlashTimeout, Timer*, void); + +public: + SalFlashAttention(VclPtr<vcl::Window> xWidget) + : m_xWidget(std::move(xWidget)) + , m_aFlashTimer("SalFlashAttention") + , m_bOrigControlBackground(false) + , m_nFlashCount(1) + { + m_aFlashTimer.SetTimeout(150); + m_aFlashTimer.SetInvokeHandler(LINK(this, SalFlashAttention, FlashTimeout)); + } + + void Start() + { + m_bOrigControlBackground = m_xWidget->IsControlBackground(); + if (m_bOrigControlBackground) + m_aOrigControlBackground = m_xWidget->GetControlBackground(); + m_aFlashTimer.Start(); + } + + ~SalFlashAttention() { ClearFlash(); } +}; + +IMPL_LINK_NOARG(SalFlashAttention, FlashTimeout, Timer*, void) { Flash(); } + void SalInstanceWidget::ensure_event_listener() { if (!m_bEventListener) @@ -599,73 +666,6 @@ VclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const DeviceFormat::DEFAULT); } -class SalFlashAttention -{ -private: - VclPtr<vcl::Window> m_xWidget; - Timer m_aFlashTimer; - Color m_aOrigControlBackground; - Wallpaper m_aOrigBackground; - bool m_bOrigControlBackground; - int m_nFlashCount; - - void SetFlash() - { - Color aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()); - m_xWidget->SetControlBackground(aColor); - } - - void ClearFlash() - { - if (m_bOrigControlBackground) - m_xWidget->SetControlBackground(m_aOrigControlBackground); - else - m_xWidget->SetControlBackground(); - } - - void Flash() - { - constexpr int FlashesWanted = 1; - - if (m_nFlashCount % 2 == 0) - ClearFlash(); - else - SetFlash(); - - if (m_nFlashCount == FlashesWanted * 2) - return; - - ++m_nFlashCount; - - m_aFlashTimer.Start(); - } - - DECL_LINK(FlashTimeout, Timer*, void); - -public: - SalFlashAttention(VclPtr<vcl::Window> xWidget) - : m_xWidget(std::move(xWidget)) - , m_aFlashTimer("SalFlashAttention") - , m_bOrigControlBackground(false) - , m_nFlashCount(1) - { - m_aFlashTimer.SetTimeout(150); - m_aFlashTimer.SetInvokeHandler(LINK(this, SalFlashAttention, FlashTimeout)); - } - - void Start() - { - m_bOrigControlBackground = m_xWidget->IsControlBackground(); - if (m_bOrigControlBackground) - m_aOrigControlBackground = m_xWidget->GetControlBackground(); - m_aFlashTimer.Start(); - } - - ~SalFlashAttention() { ClearFlash(); } -}; - -IMPL_LINK_NOARG(SalFlashAttention, FlashTimeout, Timer*, void) { Flash(); } - void SalInstanceWidget::call_attention_to() { m_xFlashAttention.reset(new SalFlashAttention(m_xWidget)); |