diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-01-03 14:35:38 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-01-03 14:35:38 +0100 |
commit | 803f4743372aa51be123533115afa97a47336d54 (patch) | |
tree | a6f263ce7ba841d72838a31ec2e51126b6a4d777 | |
parent | f82cd9c786933a641ab131758a9fc1bd291824cc (diff) |
Mark [Scoped]VclPtrInstance as SAL_WARN_UNUSED
Stack-allocated instances of the non-Instance [Scoped]VclPtr variants are
occasionally used merely for the side-effect of holding objects alive (like
css::uno::Reference and rtl::Reference, which are also not SAL_WARN_UNUSED for
that reason).
Change-Id: I37ebfaf028a646cb2777c0baf0d99992057a22bd
-rw-r--r-- | include/vcl/vclptr.hxx | 4 | ||||
-rw-r--r-- | vcl/qa/cppunit/lifecycle.cxx | 40 |
2 files changed, 34 insertions, 10 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index 31f97dc50602..39e4fe918d52 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -295,7 +295,7 @@ template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { * @param reference_type must be a subclass of vcl::Window */ template <class reference_type> -class VclPtrInstance : public VclPtr<reference_type> +class SAL_WARN_UNUSED VclPtrInstance : public VclPtr<reference_type> { public: template<typename... Arg> VclPtrInstance(Arg &&... arg) @@ -407,7 +407,7 @@ protected: #pragma warning(disable: 4521) // " multiple copy constructors specified" #endif template <class reference_type> -class ScopedVclPtrInstance : public ScopedVclPtr<reference_type> +class SAL_WARN_UNUSED ScopedVclPtrInstance : public ScopedVclPtr<reference_type> { public: template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index 0ec8b4cd17d8..67f2e9bce9db 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -92,18 +92,42 @@ void LifecycleTest::testMultiDispose() void LifecycleTest::testWidgets(vcl::Window *pParent) { - { ScopedVclPtrInstance< PushButton > aPtr( pParent ); } - { ScopedVclPtrInstance< OKButton > aPtr( pParent ); } - { ScopedVclPtrInstance< CancelButton > aPtr( pParent ); } - { ScopedVclPtrInstance< HelpButton > aPtr( pParent ); } + { + ScopedVclPtrInstance< PushButton > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< OKButton > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< CancelButton > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< HelpButton > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } // Some widgets really insist on adoption. if (pParent) { - { ScopedVclPtrInstance< CheckBox > aPtr( pParent ); } - { ScopedVclPtrInstance< Edit > aPtr( pParent ); } - { ScopedVclPtrInstance< ComboBox > aPtr( pParent ); } - { ScopedVclPtrInstance< RadioButton > aPtr( pParent ); } + { + ScopedVclPtrInstance< CheckBox > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< Edit > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< ComboBox > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } + { + ScopedVclPtrInstance< RadioButton > aPtr( pParent ); + (void)aPtr; // silence unused variable warning + } } } |