[Libreoffice-commits] core.git: include/vcl vcl/qa
Stephan Bergmann
sbergman at redhat.com
Tue Jan 3 13:38:48 UTC 2017
include/vcl/vclptr.hxx | 4 ++--
vcl/qa/cppunit/lifecycle.cxx | 40 ++++++++++++++++++++++++++++++++--------
2 files changed, 34 insertions(+), 10 deletions(-)
New commits:
commit 803f4743372aa51be123533115afa97a47336d54
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jan 3 14:35:38 2017 +0100
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
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index 31f97dc..39e4fe9 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 0ec8b4c..67f2e9b 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
+ }
}
}
More information about the Libreoffice-commits
mailing list